I have a thread that is blocking on a Networkstream Read call. How do I best abort this thread? I tried calling Thread.Abort on the thread from another thread, which according to MSDN should raise a ThreadAbortException. However the ThreadAbortException is not raised at all in the thread. It is however, when I remove the blocking Read call and just have the thread sit in a loop. What is the best way to do this? Can I wait on the Read call and an event at the same time so the thread unblocks if either occurs? Then I could just signal that event from another thread.
I have a thread that is blocking on a Networkstream Read call. How do
Share
Thread.Abortonly aborts when the thread is running managed code, but your thread is waiting on the unmanaged socket, so nothing happens until the socket unblocks.Closing the socket is the best option here.