I am self-training on the TPL-Dataflow, and I have read that using immutable objects for messages is the way to go.
To comply with this, I have designed specific classes for every block inputs and outputs.
Unfortunately, when I link my block each other, because the blocks input and output types are very different, it leads to a proliferation of TransformBlock
:
var proc1 = new TransformBlock<proc1In,proc1Out>(...
var convertOut1toIn2 = new TransformBlock<proc1Out,proc2In>(p1 => new proc2In { ...
var proc2 = TransformBlock<proc2In,proc2Out>(...
proc1.LinkTo(convertOut1ToIn2);
convertOut1ToIn2.LinkTo(proc2);
Using Batch and Join blocks later to merge results together makes me struggle with a very messy code.
Every samples I read on the internet uses simple types as int
, string
... I have not found anything that deals with a bit more complex types.
I feel the urge to use single big object and pass its reference through all the blocks. Before doing this mistake, I would like to know if there is some better way to do.