The block is greedy, but not because of how it handles the items above 100, but the ones below 2. You can set the greedy value to false
(true
is the default) and then the block would only actually consume items when there are enough to send a batch, until then they are postponed:
var batchBlock = new BatchBlock<int>(2, new GroupingDataflowBlockOptions
{
Greedy = false,
BoundedCapacity = 100.
});
The BatchBlock class operates in either greedy or non-greedy mode. In greedy mode, which is the default, a BatchBlock object accepts every message that it is offered and propagates out an array after it receives the specified count of elements. In non-greedy mode, a BatchBlock object postpones all incoming messages until enough sources have offered messages to the block to form a batch
From Dataflow (Task Parallel Library)