I need to terminate a frozen thread, I set IsBackground as true but it stays alive. Thread’s properties:
ThreadState = AbortRequested
IsBackground = true
When I examine the frozen spot I find the line below:
resultDetect = Detect(input, ref output);
The spot is a 3rd party code (Method Detect). The thread only updates resultDetect as you see. I need to abort that thread and re-start a new one to continue. Otherwise, the application waits and does nothing -fresh resultDetect needed-
How can I kill the thread that doesn’t die?
There’s only one way to safely kill a hung thread in your application: Environment.Exit And even that can fail if the thread is running kernel code.
It’s best not to use third-party code that hangs. If you have no choice, then run it in a separate process.