Groups | Blog | Home
all groups > c# > june 2006 >

c# : Doubt related to windows based timer.


archana
6/15/2006 11:44:43 PM
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.
Marc Gravell
6/16/2006 12:00:00 AM
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

Ignacio Machin ( .NET/ C# MVP )
6/16/2006 9:20:00 AM
Hi,

[quoted text, click to view]

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 ?



--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation



AddThis Social Bookmark Button