I've a problem of Producer/Consumer. Currently I've a simple Queue
surrounded by a lock
.
I'm trying to replace it with something more efficient.
My first choice was to use a ConcurrentQueue
, but I don't see how to make my consumer wait on the next produced message(without doing Thread.Sleep).
Also, I would like to be able to clear the whole queue if its size reach a specific number.
Can you suggest some existing class or implementation that would match my requirements?