I would like to know whether it is possible to change the completion state of data blocks?
For example, I marked a var block = new BufferBlock
No, you can't “uncomplete” a completed dataflow block. I think what you should do is to add a flag to each message that says whether it's last message in a run. To make it simpler to work with it, you could create set of helper methods like:
public static TransformBlock<Tuple<TInput, bool>, Tuple<TOutput, bool>>
CreateEnhancedTransformBlock<TInput, TOutput>(Func<TInput, TOutput> transform)
{
return new TransformBlock<Tuple<TInput, bool>, Tuple<TOutput, bool>>(
tuple => Tuple.Create(transform(tuple.Item1), tuple.Item2));
}
This way, you enter a transform
delegate that deals just with TInput
and TOuput
and the flag is transfered along with each message.