Cancel TcpListener.Accept()

music7611

Freshman
Joined
Jan 24, 2004
Messages
35
I have a network waiting for a connection on its own thread. (TcpListener.AcceptSocket()). Anywho, I need the thread to be able to abort while this is happening. I tried doing Thread.Abort(), but it doesn't work! I am using C#. Thankyou for your time and energy in this matter.
 
maybe you should stop the listener first, normally Thread.Abort should work do you use a try and catch ?
 
I have a try and chatch thingy, and it does catch exception ThreadAbortException, but when I used the debugger, I found that that part of the code didn't even execute. Even when I called Thread.Abort.
 
for that reason i dont use it that way
i really prefer asynchronous server
there is also an example in the msdn for that way
 
Back
Top