Obviously, BoundedCapacity does include elements that are processed on top of elements waiting for an input queue. This can be easily demonstrated with an ActionBlock that has the same ExecutionDataflowBlockOptions with an action that never ends:
var block = new ActionBlock<int>( _ => Task.Delay(-1), new ExecutionDataflowBlockOptions { BoundedCapacity = 1000, MaxDegreeOfParallelism = 10, }); for (int i = 0; i < 1001; i++) { Console.WriteLine("#{0} - InputCount={1}", i, block.InputCount); await block.SendAsync(i); }
The result will be as follows, and then the application will block indefinitely:
... ...
That, since 1000 elements were added, 10 of them ( MaxDegreeOfParallelism ) are processed at the same time, the remaining 990 are waiting in the input queue, and element 1001 st will never be able to enter.
source share