How to terminate a managed thread blocked in unmanaged code?
- by James Curran
I have a managed thread which is waiting, blocked, in an unmanaged code (specifically, it on a call to NamedPipeServerStream.WaitForConnection() which ultimitely calls into unmanaged code, and does not offer a timeout).
I want to shut the thread down neatly.
Thread.Abort() has no effect until the code returns to the managed realm, which it won't do until a client makes a connection, which we can't wait for).
I need a way "shock" it out of the unmanaged code; or a way to just kill the thread even while it's in unmanaged land.