C# Threading.Suspend in Obsolete, thread has been deprecated?

前端 未结 3 1417
忘掉有多难
忘掉有多难 2021-02-05 22:19

In my application, I am performing my file reading by another thread(other that GUI thread). There are two buttons that suspend and resume the Thread respectively.



        
3条回答
  •  太阳男子
    2021-02-05 22:38

    The reason Suspend and Resume are deprecated is because there are no guarantees at what point in the execution the thread will be suspended on. This is a bad thing. The issue is described here as well as a solution.

    The solution should involved a WaitHandle (maybe AutoResetEvent or ManualResetEvent) which you can use to signal to your autoReadThread to stop/start.

提交回复
热议问题