What is the difference between ManualResetEvent and AutoResetEvent in .NET?

后端 未结 11 2202
慢半拍i
慢半拍i 2020-11-27 09:06

I have read the documentation on this and I think I understand. An AutoResetEvent resets when the code passes through event.WaitOne(), but a ManualResetEvent do

11条回答
  •  时光取名叫无心
    2020-11-27 09:29

    autoResetEvent.WaitOne()

    is similar to

    try
    {
       manualResetEvent.WaitOne();
    }
    finally
    {
       manualResetEvent.Reset();
    }
    

    as an atomic operation

提交回复
热议问题