Data Propagation in TPL Dataflow Pipeline with Batchblock.Triggerbatch()

后端 未结 2 1838
一个人的身影
一个人的身影 2021-01-24 19:32

In my Producer-Consumer scenario, I have multiple consumers, and each of the consumers send an action to external hardware, which may take some time. My Pipeline looks somewhat

2条回答
  •  执笔经年
    2021-01-24 19:56

    I have found that using TriggerBatch in this way is unreliable:

        _groupReadTags.Post(10);
        _groupReadTags.Post(20);
        _groupReadTags.TriggerBatch();
    

    Apparently TriggerBatch is intended to be used inside the block, not outside it like this. I have seen this result in odd timing issues, like items from next batch batch being included in the current batch, even though TriggerBatch was called first.

    Please see my answer to this question for an alternative using DataflowBlock.Encapsulate: BatchBlock produces batch with elements sent after TriggerBatch()

提交回复
热议问题