We've expanded our news coverage and improved our search!
for the latest or search for all things across O'Reilly!
Plumbing the Depths of the ThreadAbortException Using Rotor
let's say that the working thread(the one which eventually we want to Abort) waits on a process to exit
// main thread
the problem is that the exception is not thrown ! the main thread waits on the thread to join until the thread exists. the Abort() is not delivered but until the thread exists (returns from Process.WaitForExit).
i was looking for an explaination but could not find any since now.
If the Abort() queues an APC to the thread, it seems that this is not processed because the thread is not on an alertable state.
And it stays that way, it's not even put by the scheduler and this is because it seems like its a non-waitable wait function like WaitForSingleObject on the process handle.
but thats not all.
i tried something else. instead of waiting with Process.WaitForExit() on the process, i used pinvoke and called:
Process proc = Process.GetProcessById(3504);
WaitForSingleObjectEx(proc.Handle, -1, 1); // last value tells that the wait is alertable
this does NOT work either !
what is happening with that thread !?