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

后端 未结 11 2211
慢半拍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条回答
  •  萌比男神i
    2020-11-27 09:20

    Yes, thats right.

    You can get an idea by the usage of these two.

    If you need to tell that you are finished with some work and other (threads) waiting for this can now proceed, you should use ManualResetEvent.

    If you need to have mutual exclusive access to any resource, you should use AutoResetEvent.

提交回复
热议问题