Benefits of using BufferBlock in dataflow networks

后端 未结 3 790
隐瞒了意图╮
隐瞒了意图╮ 2021-02-01 21:59

I was wondering if there are benefits associated with using a BufferBlock linked to one or many ActionBlocks, other than throttling (using BoundedCapacity), instead of just post

3条回答
  •  生来不讨喜
    2021-02-01 22:34

    No, the second example won't compile for a number of reasons: It's only possible to set greedy=false for a "grouping" dataflow block - not for an execution block; and then it has to be set via GroupingDataflowBlockOptions - not DataflowBlockOptions; and then it is set as a property value "{ Greedy = false }" not a constructor parameter.

    If you want to throttle the capacity of an action block, do it by setting the value of the BoundedCapacity property of DataflowBlockOptions (though as the OP stated, they're already aware of this option). Like this:

    var a1 = new ActionBlock(
                i => doSomeWork(i), 
                new ExecutionDataflowBlockOptions {BoundedCapacity = 1}
            );
    

提交回复
热议问题