Manipulating data from multiple data sources
A JoinBlock
can be configured to receive different data types from two or three data sources. As each set of data types is completed, the block is completed with a Tuple
containing all three object types to be acted upon. In this example, we will create a JoinBlock
that accepts a string
and int
pair and passes Tuple(string, int)
along to an ActionBlock
, which outputs their values to the console. Follow these steps:
- Start by creating a new console application in Visual Studio
- Add a new class named
DataJoiner
to the project and add a static method to the class namedJoinData
:public static void JoinData() { }
- Add the following code to create two
BufferBlock
objects, aJoinBlock<string, int>
, and anActionBlock<Tuple<string, int>>
:var stringQueue = new BufferBlock<string>(); var integerQueue = new BufferBlock<int>(); var joinStringsAndIntegers = new JoinBlock<string, int...