c#中manualresetevent怎么设置

lewis 2016-12-04 20次阅读

在C#中,通过以下步骤可以设置ManualResetEvent:

  1. 创建一个ManualResetEvent对象:
ManualResetEvent manualResetEvent = new ManualResetEvent(false);
  1. 在需要等待信号的地方调用WaitOne()方法:
manualResetEvent.WaitOne();
  1. 在需要发送信号的地方调用Set()方法:
manualResetEvent.Set();
  1. 如果需要重新设置ManualResetEvent为未发信号状态,可以调用Reset()方法:
manualResetEvent.Reset();

通过这些步骤,可以在C#中设置和使用ManualResetEvent。



发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。