How can I stop a thread in C#?

前端 未结 4 1575
逝去的感伤
逝去的感伤 2021-01-16 05:27

I\'ve created a Client-Server application, and on the Server I want to have the oportunity to stop the server and then start it again. The problem is that I can\'t stop the

4条回答
  •  广开言路
    2021-01-16 06:09

    Yor Question is a little general, but, I think that this may help you:

    Threads in C#

    I paste a portion:

    Stopping a Thread

    Normally, when a thread is started, it runs until finished. However, it is possible to stop a thread by calling the Abort() method. In our example, if we want to stop firstThread, you would add the following code.

    Read more at Suite101: How to Create, Stop and Suspend Threads in C# | Suite101.com http://www.suite101.com/article.cfm/c_sharp/96436#ixzz0ZsZRRjKx

    Happy coding!

提交回复
热议问题