Home > Mobile >  Does Complete execute Trigger for DataFlow blocks?
Does Complete execute Trigger for DataFlow blocks?

Time:11-10

I have two pipelines using multiple Buffer, Batch, and Action blocks from the System.Threading.Tasks.Dataflow namespace. I understand once all work items have been added to the pipeline that the Complete method should be called. However, if the Batch blocks are processing 250 items at a time, will calling the Complete method actual call the Trigger method internal to ensure any pending items are completed.

For example, if the Batch blocks are batching 250 items at a time, 251 items are given to the pipeline, and Complete is called, will the one remaining item be processed by the entire pipeline? If not, I am assuming I will need to implement my own flag and logic to ensure all remaining items are passed through the pipeline as well as the second one?

CodePudding user response:

When a BatchBlock<T> is marked as complete with the Complete method, it stops accepting any more messages, and emits a final batch containing any leftover messages that are currently in its input queue. Obviously the size of the last batch can be smaller that the specified batchSize. In short you don't have to do anything special. The BatchBlock<T> does the correct thing by itself.

When the last batch stored in the output queue of the BatchBlock<T> is accepted by a linked block downstream, the BatchBlock<T>'s Completion property transitions to the RanToCompletion state.

  • Related