How to terminate a thread in C#?

前端 未结 4 1629
無奈伤痛
無奈伤痛 2020-11-27 20:38

I wanted to try my luck in threading with C#, I know a few things about threading in C.

So I just wanted to ask if i wanted to terminate a thread, I should do it wi

4条回答
  •  囚心锁ツ
    2020-11-27 20:50

    Terminating a thread externally (from outside the thread) is a bad idea; you never know what the thread was in the middle of doing when you kill it asynchronously. In C#, if your thread function returns, the thread ends.

    This MSDN article How to: Create and Terminate Threads (C# Programming Guide) has some notes and some sample code that you will probably find helpful.

提交回复
热议问题