I've read a few other similiar-but-not-the-same links trying to find some answers: How to consume a BlockingCollection<T> in batches
However, (in the above link) not using GetConsumingEnumerable seems fishy.
What is the correct method to effectively block producers while the consumer (should be singular) empties the collection?
[We want to do batch-processing because each batch does a web service call which would be a bottle neck if every single message/item needed its own call. Batching the messages/items is the solution for this bottleneck.]
Ideally:
1) Receive message
2) New producer task to push into collection
3) When collection 'full' (arbitrary limit), block all producer(s), new consumer task to consume ALL of the collection, then unblock for producer(s).
In other words; I want (parallel producers) xor (single consumer) acting on the collection at any time.
Seems like this should have been done before, but I can't seem to find a code snippet that specifically acts this way.
Thanks for any help.