catch (ThreadAbortException)
{ }
catch (Exception ex)
{
TraceManager.TraceException(ex,
(int)ErrorCode.GENERIC_EXCEPTION,
ThreadAbortException cannot be caught "completely"; it will automatically be rethrown at the end of the catch
block (see the linked MSDN docs page) unless Thread.ResetAbort is called first.
So, the only sensible catch
block would be:
catch (ThreadAbortException)
{
// possibly do something here
Thread.ResetAbort();
}
But this has a really evil smell. There's probably no reason to do it, so you may want to rethink your approach.
Update:
There are many questions on SO that deal with Thread.Abort
:
This one has the same answer as I have given here.
This one has an answer that expands on "don't ever call Thread.Abort
unless Cthulhu is rising" (which I toned down considerably to an "evil smell").
There are also many others.