I stop a thread execution with .Abort() and .Join() for wait the thread terminates. But the problem is that .Join() never unblock application, same when thread was terminated. Why? my code:
th.Abort();
Console.WriteLine("request sent, please wait..");
th.Join();
Console.WriteLine("done!");
the above code never unlock application, but it works fine:
th.Abort();
Console.WriteLine("request sent, please wait..");
while (serverTh.ThreadState != ThreadState.Aborted) {
Thread.Sleep(500);
}
Console.WriteLine("done!");
Thanks in advance.
What’s going on in the thread that you are trying to abort? For instance, this works fine:
The only thing that comes to mind is maybe your background thread is catching the AbortException and then calling ResetAbort on itself: