Does it make sense to catch ThreadAbortException and perform no action?

后端 未结 5 2246
旧时难觅i
旧时难觅i 2021-02-20 01:31
catch (ThreadAbortException)
{ }
catch (Exception ex)
{
    TraceManager.TraceException(ex,
                                (int)ErrorCode.GENERIC_EXCEPTION,
                    


        
5条回答
  •  面向向阳花
    2021-02-20 01:43

    The ThreadAbortException can't be caught like that. It will get rethrown automatically at the end of the catch block unless you call Thread.ResetAbort();

    Having a catch block as you have here for ThreadAbortException allows it to be auto-rethrown without the catch(Exception) block attempting to handle it.

提交回复
热议问题