What's wrong with using Thread.Abort()

前端 未结 7 1839
执笔经年
执笔经年 2020-11-21 22:30

So I know that you shouldn\'t use

Thread.Abort()

But I\'ve never been given a good explanation. Is there a performance penalty or some hid

7条回答
  •  迷失自我
    2020-11-21 22:51

    Thread.Abort stops your thread in an uncontrolled fashion. thread.Abort will throw an exception, which will cause that your thread stops immediatly.

    What is wrong with that: in most cases, you want to gracefully stop the operation that you're performing. For instance, if you are executing an ACID operation, you might want to complete the current operation before ending the thread, so that your system remains in a stable state.

提交回复
热议问题