I'm toying with the idea of implementing a generic Producer/Consumer pair + processing queue in C# for fun. The idea is you can just create objects that implement appropriate IProducer and IConsumer interfaces (default implementations supplied), which will consist mainly of delegates, pass them to a QueueProcessor
class instance, tell it how many consumers you want, and go.
But I say to myself, "Self, surely this has been done before."
So does anyone know of a good, generic implementation of the producer/consumer pattern in C# (VB.Net is okay, too)? The basic requirements I'm looking for:
Or if there is none, what pitfalls have prevented it and do you have any thoughts on how to implement it?
Microsoft CCR contains much of what you need.
Here are some code samples and usage notes.
Marc Gravell wrote a nice example blocking queue in this answer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With