Skip to content
Howard van Rooijen By Howard van Rooijen Co-Founder
TPL Dataflow by Example code samples for LINQPad

Reactive Programming and in particular Task Parallel Library Dataflow has been on my radar for a number of years after reading  Stephen Toub's "Introduction to TPL Dataflow" whitepaper and watching his Channel9 videos (TPL Dataflow Tour, Inside TPL Dataflow). Unfortunately all of my research time of late has been absorbed trying to keep up with the rapidly changing Microsoft Azure ecosystem, until over the Christmas period I finally got the chance to consume both of Matt Carkci's excellent books on the subject:

dataflow-and-reactive-programming

Dataflow and Reactive Programming Systems: A Practical Guide

tpldataflow-by-example

Programming C# 10 Book, by Ian Griffiths, published by O'Reilly Media, is now available to buy.

TPL Dataflow by Example: Dataflow and Reactive Programming in .Net

Dataflow & Reactive Programming Systems is a more detailed overview of the theory of the dataflow and reactive paradigms (with examples in Haskell), whereas TPL Dataflow by example is a step by step guide of how the paradigms have been implemented in the .NET ecosystem with TPL Dataflow.

TPL Dataflow by Example does have code samples available, but they are raw .cs files (as the author states there isn't a "Visual Studio project due to the number of versions of Visual Studio that exist"). I decided on a slightly different approach – I've been a fan of LINQPad for a number of years as one of it's really neat features is the Samples Library that enables you to create a collection of code samples – a feature that has been used by many book authors for publishing their code samples.

First download the TPL Dataflow by Example sample file.

Next, open LINQPad, select the "Samples" tab and click the "Download / Import more samples" link:

image

This will pop open the Browse Sample Libraries window. Select the browse link, navigate to and select the sample file you just downloaded:

image

Now you should see the new "TPL Dataflow by Example – Matt Carkci" folder with a list of files:

image

You should be able to just press the run button, the required TPL Dataflow NuGet package should automatically download, then the code sample should run.

I've made a few structural changes to the original code samples in order to make them run in LINQPad, otherwise everything else should be the same. Hopefully if you're interested in Dataflow & have purchased the book, this might help you run through the examples more easily.

The Introduction to Rx.NET 2nd Edition (2024) Book, by Ian Griffiths & Lee Campbell, is now available to download for FREE.

Creating a sample library is very simple – follow these instructions to make your own.

Update: Joe Albahari points out that LINQPad actually supports Dataflow block:

dataflow

@HowardvRooijen | @endjin

Howard van Rooijen

Co-Founder

Howard van Rooijen

Howard spent 10 years as a technology consultant helping some of the UK's best known organisations work smarter, before founding endjin in 2010. He's a Microsoft ScaleUp Mentor, and a Microsoft MVP for Azure and Developer Technologies, and helps small teams achieve big things using data, AI and Microsoft Azure.