Filtering custom blocks with LinkTo


  • Hello,

    I wrote a simple wrapper block (real wrapper is a little bit more complex, but this is simplest one that reproduce my problem):

    WrapperBlock<TInput,TOutput> : IPropagatorBlock<TInput,TOutput>
      private IPropagatorBlock<TInput,TOutput> propagator;
      public WrapperBlock(IPropagatorBlock<TInput,TOutput> propagator)
        this.propagator = propagator;
      //explicit IPropagatorBlock<,> implementation that
      //calls private propagator.

    Now when i run following code the predicate in LinkTo method is never called.

    var buf = new WrapperBlock<int,int>(new BufferBlock<int>());
    var act = new ActionBlock<int>(x => Console.WriteLine(x));
    buf.LinkTo(act, x => x < 5);

    Is it a problem with internal FilteredLinkPropagator or shall I implement some more sophisticated wrapper block?


    I'm using TPLDataflow.msi from DevLabs web page on VS2010 and .Net 4.0.

    Best Regards,


    • Edited by Hubert Bukowski Tuesday, December 04, 2012 3:21 PM Version info added
    Tuesday, December 04, 2012 9:25 AM


All replies

  • If you waited for buf.Completion, you would find out what the problem is, because it throws ArgumentException:

    This block must only be used with the source from which it was created. Parameter name: source

    Right now, I'm not sure how to properly fix this, I'll think about that.

    Tuesday, December 04, 2012 7:56 PM
  • Unfortunately I think this is a bug in dataflow (see for another example of it).  If it's the same thing, the team is aware of it and is planning to fix it, though I don't know for when.

    Wednesday, December 05, 2012 1:34 AM
  • Yes, I have checked similar scenario using Encapsulate and the problem is the same.

    I did not find this question before.

    We are currently unable to upgrade to .Net 4.5. Is there any possibility that the fix will be merged to .Net 4.0 version of TDF?

    Wednesday, December 05, 2012 10:05 AM
  • Hi LeetBaal,<o:p></o:p>

    The bug was fixed in the latest version of the TPL Dataflow. TPL Dataflow NuGet package version 4.5.9. Unfortunately it is the TPL Dataflow version for .Net Framework 4.5. <o:p></o:p>

    We encourage you to upgrade to .Net Framework 4.5. Are there any issues the block you from upgrading to the new .Net Framework version? We are happy to learn about and help in solving them. Please let us know.<o:p></o:p>



    Friday, January 04, 2013 9:41 PM
  • Hello Cristina,

    Thanks for your information and sorry for late response. There were no special issues that blocked us from upgrade. I just checking if .Net 4 version of TPL is supported or shall we wait for our VS2012 upgrade to use the fixed version of TPL. In the matter of fact we are now using VS2012 so we are moving to NuGet version.

    Best Regards,


    Sunday, April 14, 2013 2:58 PM