I have a main application [frmMain] that launches threads (tcp listeners) - at a certain point I want to STOP these threads (which will close my listener, sockets, and abort the thread - this all works fine).
Thing is it also launches 2 exceptions:
- SocketException: A blocking operation was interrupted by a call to WSACancelBlockingCall
- ThreadAbortException: Thread was being aborted.
This is my current CATCH-phase code:
Now I am pretty sure I can catch the Thread Abort Exception using: "catch (ThreadAbortException) {}" first on the list...
But I have no clue how to "catch" the specific Socket Exception ("A blocking operation was interrupted by a call to WSACancelBlockingCall") so that it does NOT log as an exception (it is perfectly fine that it was interrupted by me when aborting the thread), not as simple as ThreadAbort... How can I determine if this is NOT an exception I want to log?
Any ideas, hints, and help would be greatly appreciated, thanks
Thing is it also launches 2 exceptions:
- SocketException: A blocking operation was interrupted by a call to WSACancelBlockingCall
- ThreadAbortException: Thread was being aborted.
This is my current CATCH-phase code:
Code:
catch (SocketException sex)
{ Log.Trace("Socket Exception: " + sex); }
catch (Exception ex)
{ Log.Trace("General Exception: " + ex); }
Now I am pretty sure I can catch the Thread Abort Exception using: "catch (ThreadAbortException) {}" first on the list...
But I have no clue how to "catch" the specific Socket Exception ("A blocking operation was interrupted by a call to WSACancelBlockingCall") so that it does NOT log as an exception (it is perfectly fine that it was interrupted by me when aborting the thread), not as simple as ThreadAbort... How can I determine if this is NOT an exception I want to log?
Any ideas, hints, and help would be greatly appreciated, thanks