简体   繁体   English

递增autoresetevent c#

[英]incrementing autoresetevent c#

Is there an incrementing AutoResetEvent, or something similar in c# libraries? 是否有递增的AutoResetEvent或c#库中的类似内容?

How would one go about rolling an efficient implementation of one, or alternatively, address the problem stated without doing so? 如何推出有效的解决方案,或者解决未解决的问题呢?

Problem: To clarify my need, I have a producer / consumer situation, where I have an unknown number of producers, and a fixed number of consumers. 问题:为明确我的需求,我遇到了生产者/消费者的情况,其中生产者的数量未知,而消费者的数量却是固定的。

Edit :Forgot to mention one issue, I cannot use .NET 4.0 so I cannot use ConcurrentQueue<T> :'( , I need to stick with .NET 2.0 for now. 编辑 :忘记提到一个问题,我不能使用.NET 4.0,所以我不能使用ConcurrentQueue<T> :'(,我现在需要坚持使用.NET 2.0。

检查信号量是否适用于您的方案。

Have you seen .NET 4's ConcurrentQueue<T> ? 您是否看到过.NET 4的ConcurrentQueue<T> It takes care of all of that for you. 它会为您解决所有这些问题。

Since you can't use .NET 4, you can use AutoResetEvent in the System.Threading namespace. 由于无法使用.NET 4,因此可以在System.Threading命名空间中使用AutoResetEvent

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM