Doubt related to windows based timer.

A

archana

Hi all,

I am having one confusion regarding windows based timer.

I read somewhere that

'Be careful with stopping, because stopped timers are disabled and are
subject to garbage collection. That means that stopped timers can not
be started again.'


I have one application containing start and stop and i am using windows
based timer.

But after clicking on stop and starting the timer again it is working
properly. And i haven't reinitialize timer object.

I am not getting whether statement which i mention above is right and
am i doing something wrong.

Please correct me if i am wrong.

Thanks in advance.
 
M

Marc Gravell

This quote doesn't sound right to me...

Garbage collection only occurs when something goes out of sight of all
accessible objects (allowing for weak-references) - so if you can still see
it, it shouldn't be collected... and if you /can't/ see it (and it is
stopped, so not firing any events), then you can't restart it anyhows...

I'm willing to believe I could be wrong, though!

Marc
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

archana said:
Hi all,

I am having one confusion regarding windows based timer.

I read somewhere that

'Be careful with stopping, because stopped timers are disabled and are
subject to garbage collection. That means that stopped timers can not
be started again.'

Not completety right, it may say that a timer with no reference to it can be
GC if stopped.
If you keep a reference to the timer it will not be GC'ed and will behave as
another regular object.

Where did you read that ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top