I'm using a TPL Dataflow with this initial network:
(a)CustomSource => (b)TransformBlock
When a message arrives in b, b creates a new transform block with a filter and append it to itself (it does not that for each message).
The network becomes like that:
(a)CustomSource => (b)TransformBlock => (c with linkto filter)TransformBlock
After a few runs the network becomes like that:
(a)CustomSource => (b)TransformBlock
=> (c with linkto filter)TransformBlock
=> (c with another linkto filter)TransformBlock
=> (c with another linkto filter)TransformBlock
This works nice, and is the only solution i found to get a default action for a "switch" block.
But when the source is completed by calling customSource.Complete(), it throws an exception :
ArgumentException: This block must only be used with the source from which it was created at System.Threading.Tasks.Dataflow.DataflowBlock.FilteredLinkPropagator
1.System.Threading.Tasks.Dataflow.ITargetBlock<T>.OfferMessage(DataflowMessageHeader messageHeader, T messageValue, ISourceBlock
1 source, Boolean consumeToAccept) at System.Threading.Tasks.Dataflow.Internal.SourceCore1.OfferMessageToTarget(DataflowMessageHeader header, TOutput message, ITargetBlock
1 target, Boolean& messageWasAccepted) at System.Threading.Tasks.Dataflow.Internal.SourceCore1.OfferToTargets(ITargetBlock
1 linkToTarget) at System.Threading.Tasks.Dataflow.Internal.SourceCore`1.OfferMessagesLoopCore()