Threads pausing and resuming c#

前端 未结 5 1326
心在旅途
心在旅途 2021-01-13 19:39

I\'ve got several threads ,how can I pause/resume them?


From duplicate question:

How can i pause 5 threads, and to remember their status. Because one o

5条回答
  •  一生所求
    2021-01-13 20:14

    In the main thread:

    ManualResetEvent re = new ManualResetEvent(true);
    

    In all the threads, at "strategic" points:

    re.WaitOne();
    

    In the main thread, to stop the threads:

    re.Reset();
    

    and to restart:

    re.Set();
    

提交回复
热议问题