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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ThunderMusic

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

    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


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

    #2
    Re: Component/Control using threads how can I do........

    Hi,


    "ThunderMus ic" <NoSpAmdanlatat hotmaildotcom@N oSpAm.comwrote in message
    news:eX6w7RP2GH A.3516@TK2MSFTN GP06.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


    Comment

    Working...