AutoResetEvent仅在未设置时等待的最佳方式

Mic*_*eth 4 c# multithreading autoresetevent

我可能超出了AutoResetEvent的正确设计,但不太清楚要转向什么.我想要这种行为:

var autoResetEvent = new AutoResetEvent(false);
autoResetEvent.Set();
autoResetEvent.Set();
autoResetEvent.WaitOne();
// since Set was called twice, I don't want to wait here
autoResetEvent.WaitOne();
Run Code Online (Sandbox Code Playgroud)

不幸的是(对于我的问题),这不是AutoResetEvent的行为方式.在这种情况下,最好的课程是什么?

注意:我可以访问.NET Parallel Exensions库.

Dar*_*rov 6

你在寻找信号量吗?