gpt4 book ai didi

c# - AutoResetEvent 仅在未设置该次数时等待的最佳方法

转载 作者:太空狗 更新时间:2023-10-30 00:57:54 25 4
gpt4 key购买 nike

我可能超出了 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();

不幸的是(对于我的问题),这不是 AutoResetEvent 的行为方式。对于这种情况,最好使用什么类?

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

最佳答案

您是否在寻找 Semaphore

关于c# - AutoResetEvent 仅在未设置该次数时等待的最佳方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4147981/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com