Task Dataflow, can a data block be changed from completion state?

时光怂恿深爱的人放手 提交于 2019-12-01 06:06:51

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!