If you use the default constructor to construct a TPL BufferBlock
, are the DataFlowBlockOptions
unbounded? In other words, what is the BoundedCapacity
of the BufferBlock
?
As stated in this SO answer, it's not possible to query nor change the values of the BufferBlock
after construction.
You have two options to find this out: read the docs or create BufferBlock
by yourself.
From Introduction to TPL Dataflow
:
The majority of the dataflow blocks included in
System.Threading.Tasks.Dataflow.dll
support the specification of a bounded capacity.This is the limit on the number of items the block may be storing and have in flight at any one time. By default, this value is initialized to
DataflowBlockOptions.Unbounded
(-1
), meaning that there is no limit.However, a developer may explicitly specify an upper bound. If a block is already at its capacity when an additional message is offered to it, that message will be postponed.
Also, from MSDN:
DataflowBlockOptions
is mutable and can be configured through its properties.
When specific configuration options are not set, the following defaults are used:
TaskScheduler
:TaskScheduler.Default
MaxMessagesPerTask
:DataflowBlockOptions.Unbounded
(-1
)CancellationToken
:CancellationToken.None
BoundedCapacity
:DataflowBlockOptions.Unbounded
(-1
)Dataflow blocks capture the state of the options at their construction.
Subsequent changes to the providedDataflowBlockOptions
instance should not affect the behavior of a dataflow block.
You can always view private members from debugger:
You also may try to get/set them by reflection, but this is really not recommended.