I have three different TransformBlock
which take different inputs but spit out 3 derivations of the same abstract class, say AbstractBaseResult
. This AbstractBaseResult
has a property called IsSuccess
that can be filtered.
Here is the rough equivalent code:
public abstract class AbstractBaseResult
{
public bool IsSuccess {get; set;}
public Exception Error {get; set;}
}
// For brevity I cannot include it here, but block1 and block2 are second/third generation predecessors of block3 in this dataflow
var block1 = new TransformBlock<Input1, DerivedResult1>(...);
var block2 = new TransformBlock<Input2, DerivedResult2>(...);
var block3 = new TransformBlock<Input3, DerivedResult3>(...);
var batchBlock = new BatchBlock<DerivedResult3>(1000);
var dataflowLinkOptions = new DataflowLinkOptions { PropagateCompletion = true };
block3.LinkTo(batchBlock, dataflowLinkOptions, x => x.IsSuccess);
var failures = new ConcurrentBag<Exception>();
var failBlock = new ActionBlock<AbstractBaseResult>(x => failures.Add(x.Error));
block1.LinkTo(failBlock, dataflowLinkOptions, x => !x.IsSuccess);
block2.LinkTo(failBlock, dataflowLinkOptions, x => !x.IsSuccess);
block3.LinkTo(failBlock, dataflowLinkOptions, x => !x.IsSuccess);
If I comment out block1
/block2
linking to failBlock
, then the application runs fine. However if all 3 are linked, then a fail condition on block3
causes the application to hang. Any idea what could be happening here or what I am missing?