Threading Abort problem

  • Thread starter Thread starter chook.harel
  • Start date Start date
C

chook.harel

I've read the articles by MSDN and the topics here,
but still I haven't found a good way to abort a thread,
My problem is that the thread i'm trying to close is calling an
external function
and i'm counting 10 seconds in the main thread, if it didn't changed
a flag in those 10 seconds, it means it stuck and i need to terminate
it.
if it got an answer.. then everything is ok.. but still i wants to
close that thread.

If it stucks then the next time i'll try it it will raise a runtime
error which i can't catch
so there I'm stuck right now :/

What can I do to kill the thread i've opened

i've also tried
while (!thread.Join(100))
{
Console.WriteLine("Thread not aborted, trying
again.");
thread.Abort();
}

it didn't help.
 
The short answer is "you dont". Threads should only really end by
letting them to completion. It sounds like the real problem is simply
that you are calling an "external function" that is hanging. Wouldn't
it be better to debug that?
 
Back
Top