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

  • Thread starter Thread starter ThunderMusic
  • Start date Start date
T

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
 
Hi,


ThunderMusic said:
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.
 
Back
Top