0

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.FilteredLinkPropagator1.System.Threading.Tasks.Dataflow.ITargetBlock<T>.OfferMessage(DataflowMessageHeader messageHeader, T messageValue, ISourceBlock1 source, Boolean consumeToAccept) at System.Threading.Tasks.Dataflow.Internal.SourceCore1.OfferMessageToTarget(DataflowMessageHeader header, TOutput message, ITargetBlock1 target, Boolean& messageWasAccepted) at System.Threading.Tasks.Dataflow.Internal.SourceCore1.OfferToTargets(ITargetBlock1 linkToTarget) at System.Threading.Tasks.Dataflow.Internal.SourceCore`1.OfferMessagesLoopCore()

i3arnon
  • 113,022
  • 33
  • 324
  • 344
Softlion
  • 12,281
  • 11
  • 58
  • 88
  • Could you post a short code that reproduces the problem? My guess is that you're trying to offer messages from `CustomSource` directly to the `LinkTo` filter, but I have no idea how would you do that. – svick May 09 '12 at 09:46
  • I think i found the problem. One of the "c" TransformBlock was faulted. When a block is faulted it does not unlink automatically from the network. Adding a completion task to unlink the block seems to fix this problem. – Softlion May 09 '12 at 14:03
  • btw, the "c" TransformBlock faults because it is linked to one child block with a filter, but the filter always returned false. It seems TPL Dataflow does not discard the message, but faults the block. I'm using the version included in .NET 4.5 beta. – Softlion May 09 '12 at 14:05

1 Answers1

1

One of the "c" TransformBlock was faulted. When a block is faulted it does not unlink automatically from the network. Adding a completion task to unlink the block seems to fix this problem.

Softlion
  • 12,281
  • 11
  • 58
  • 88