Restarting a thread in .NET (using C#)

后端 未结 7 2308
再見小時候
再見小時候 2020-12-06 01:28

I\'m looking for a way to restart a thread that has been stopped by Abort()..

public partial class MyProgram : Form
{
  private Thread MyThread = new Thread(         


        
相关标签:
7条回答
  • 2020-12-06 02:02

    Simply add MyThread = new Thread(MyFunction) before calling MyThread.Start() in doStart(). Do not create the thread outside of your methods, the space there is thought for declarations.

    EDIT: Please note that killing a thread with thread.Abort() can be very dangerous. You should try to accomplish clean multithreading, like Groo described in his post.

    0 讨论(0)
提交回复
热议问题