Difference between Abort and Interrupt in Threads in .NET

后端 未结 4 1776
攒了一身酷
攒了一身酷 2020-12-30 05:33

What is the difference between Thraed.Abort() and Thread.Interrupt(). How can I call them in a Thread Safe Manner.It would be helpful,if simple example is provided.

4条回答
  •  星月不相逢
    2020-12-30 06:13

    The difference between Abort and Interrupt is that while they will both throw an exception (ThreadAbortException and ThreadInterruptException), calling Abort will rethrow the exception at the end of the catch block and will make sure to end your running thread.

提交回复
热议问题