WriteOnceBlock C# with Example
(Readonly variable: Memorizes its ﬁrst data item and passes out copies of it as its output. Ignores all other data
If BuﬀerBlock is the most fundamental block in TPL Dataﬂow, WriteOnceBlock is the simplest.
It stores at most one value, and once that value has been set, it will never be replaced or overwritten.
You can think of WriteOnceBlock in as being similar to a readonly member variable in C#, except instead of only
being settable in a constructor and then being immutable, it ’s only settable once and is then immutable.
Splitting a Task’s Potential Outputs
public static async void SplitIntoBlocks(this Task task,
out IPropagatorBlock result,
out IPropagatorBlock exception)
result = new WriteOnceBlock(i => i);
exception = new WriteOnceBlock(i => i);
Introduction to TPL Dataﬂow by Stephen Toub