gpt4 book ai didi

task-parallel-library - TPL 默认构造函数 BufferBlock : Value of DataFlowBlockOptions

转载 作者:行者123 更新时间:2023-12-04 03:12:24 25 4
gpt4 key购买 nike

如果使用默认构造函数构造 TPL BufferBlockDataFlowBlockOptions 是否无界?换句话说,BufferBlockBoundedCapacity 是多少?

As stated in this SO answer , 构造后无法查询或更改 BufferBlock 的值。

最佳答案

您有两种选择可以找出答案:阅读 docs或者自己创建BufferBlock

来自 TPL 数据流简介:

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.

此外,来自 MSDN :

DataflowBlockOptions is mutable and can be configured through its properties.
When specific configuration options are not set, the following defaults are used:

Dataflow blocks capture the state of the options at their construction.
Subsequent changes to the provided DataflowBlockOptions instance should not affect the behavior of a dataflow block.

您始终可以从调试器查看私有(private)成员:

from debugger

您也可以尝试通过反射来获取/设置它们,但确实不推荐这样做。

关于task-parallel-library - TPL 默认构造函数 BufferBlock : Value of DataFlowBlockOptions,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44043265/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com