I call ChannelServer.ListeningThread.Abortin the next thread, however nothing happens. I would like to be more specific, but I can't think of anything else. It does not seem ThreadAbortExceptionto be thrown, and this exception should be thrown independently of the blocking listener (it works fine on threads that block reception).
Important EDIT . When used ManualResetEvent.WaitOneinstead AcceptSocket, as Lyrik suggested for testing, it works great. Why is AcceptSocketblocking ThreadAbortException?
LINK . This forum thread seems to be discussing the same problem, although I can’t understand anything from this: http://www.tek-tips.com/viewthread.cfm?qid=319436&page=413
ChannelServer.ListeningThread = new Thread(new ThreadStart(delegate()
{
Log.Inform("Waiting for clients on thread {0}.", Thread.CurrentThread.ManagedThreadId);
while (true)
{
try
{
new Thread(new ParameterizedThreadStart(ChannelClientHandler.Initialize)).Start(ChannelServer.Listener.AcceptSocket());
}
catch (ThreadAbortException)
{
Log.Inform("Aborted client listening thread {0}.", Thread.CurrentThread.ManagedThreadId);
break;
}
}
}));
ChannelServer.ListeningThread.Start();