C# Language BroadcastBlock


(Copy an item and send the copies to every block that it’s linked to)

Unlike BufferBlock, BroadcastBlock’s mission in life is to enable all targets linked from the block to get a copy of every element published, continually overwriting the “current” value with those propagated to it.

Additionally, unlike BufferBlock, BroadcastBlock doesn’t hold on to data unnecessarily. After a particular datum has been offered to all targets, that element will be overwritten by whatever piece of data is next in line (as with all dataflow blocks, messages are handled in FIFO order). That element will be offered to all targets, and so on.

enter image description here

Asynchronous Producer/Consumer with a Throttled Producer

var ui = TaskScheduler.FromCurrentSynchronizationContext();
var bb = new BroadcastBlock<ImageData>(i => i);

var saveToDiskBlock = new ActionBlock<ImageData>(item =>

var showInUiBlock = new ActionBlock<ImageData>(item =>
    new DataflowBlockOptions { TaskScheduler = TaskScheduler.FromCurrentSynchronizationContext() }


Exposing Status from an Agent

public class MyAgent
    public ISourceBlock<string> Status { get; private set; }
    public MyAgent()
        Status = new BroadcastBlock<string>();

    private void Run()
        Status.Post("Doing cool stuff");

Introduction to TPL Dataflow by Stephen Toub