Search code examples
c#tpl-dataflow

How to properly link several BufferBlocks together?


I would like several buffer blocks (producers) to dump into one bufferblock (consumer). I tried an extension of the code below, but the consumer is not being populated with any producer data. What am I doing wrong here?

        var bbA = new BufferBlock<int>();
        var bbB = new BufferBlock<int>();
        bbB.LinkTo(bbA);
        bbA.SendAsync(1).Wait();
        bbA.SendAsync(2).Wait();
        //bbB is still empty here despite the linking? 

Solution

  • It's the other way round, you should link the source to the target.

    Try this:

    bbA.LinkTo(bbB);