Home All Groups Group Topic Archive Search About

Component/Control using threads how can I do........

Author
15 Sep 2006 6:27 PM
ThunderMusic
Hi,
I want to develop a component or a control(no UI, just like a timer or
something)...  This component will have a thread running from it's
constructor or from a start function until a stop function or the end of the
application. What I want to know is the following : How can I know when the
application stops (in case I forgot to call the stop function) so I can stop
my thread quickly? I'd use dispose, but it can be called whenever the GC
decides to and it's not always at Application end, it could be seconds or
worse, minutes later...

How should I do? Is there a sandard for this kind of behavior?

thanks

ThunderMusic

Author
15 Sep 2006 6:48 PM
Ignacio Machin ( .NET/ C# MVP )
Hi,


"ThunderMusic" <NoSpAmdanlatathotmaildotcom@NoSpAm.com> wrote in message
news:eX6w7RP2GHA.3516@TK2MSFTNGP06.phx.gbl...
> Hi,
> I want to develop a component or a control(no UI, just like a timer or
> something)...  This component will have a thread running from it's
> constructor or from a start function until a stop function or the end of
> the application. What I want to know is the following : How can I know
> when the application stops (in case I forgot to call the stop function) so
> I can stop my thread quickly? I'd use dispose, but it can be called
> whenever the GC decides to and it's not always at Application end, it
> could be seconds or worse, minutes later...

Minutes later than the application ends? don't think so :)

IMO if you mark your thread with IsBackground = true   you are safe.

Note that this does not assure you a "clean" termination, if you want to do
some cleaning you better implement the IDisposable pattern.



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

AddThis Social Bookmark Button