Thread question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?W0pvZV0=?=

    Thread question

    Hi,
    I have 3 questions , remark as Why ??? :

    I have 2 threads that run in my application, each thread is a loop with low
    level call :

    While(!AutoSetE vent.WaitOne(1, true))
    {
    DLL_Export_GetD ata(…)
    Do something with this data
    }

    Know some time I want to Abort those threads , So what I did is to create
    AutoSetEvent , when I want to stop the thread I call the Set event function.
    Then wait in loop until the thread died :
    While(thread.Is Alive())
    {
    Continue;
    }
    In the last loop I tried to add Application.DoE vent() but this cause my
    application to crash. Why ???

    The big problem is sometime the thread is go out of the loop but it is still
    Alive Why?????

    Do any one know how to do that in deferent and elegant way ????

Working...