Setting the data stream, can the data block be changed from the completion state?

I would like to know if it is possible to change the completion state of data blocks?

For example, I designated a data block var block = new BufferBlock<int>();complete with block.Complete(). A block is associated with other data blocks. I would like to know if I can start again by blockchanging its completion state to its original state.

If this is not possible, I can perform several runs, including completion, without the need to: a) delete all blocks, b) re-create all blocks and c) re-link all blocks again?

Any ideas that might make it easier to start data flow loops, including terminating each block in a chain without having to re-create the whole structure?

thank

+5
source share
1 answer

No, you cannot "incomplete" a populated data stream block. I think you should add a flag for each message that says whether the last message will be in the run. To make it easier to work with, you can create a set of helper methods, such as:

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));
}

So you enter a delegate transformthat deals only with TInputand TOuput, and the flag is passed along with each message.

+3
source

All Articles