Search code examples
c#multithreadingautoresetevent

incrementing autoresetevent c#


Is there an incrementing AutoResetEvent, or something similar in c# libraries?

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.


Solution

  • Check out if Semaphore would work for your scenario.