none
Filtering custom blocks with LinkTo

    Question

  • 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);
    buf.Post(1);
    buf.Post(3);
    buf.Post(5);
    buf.Post(8);
    buf.Post(10);
    Console.ReadKey();

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

    EDIT:

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

    Best Regards,

      Hubert


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

Answers

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 http://social.msdn.microsoft.com/Forums/en-US/tpldataflow/thread/50125974-bbc8-4087-89d3-e9434abe0928 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
    Owner
  • 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>

    Thanks,
    Cristina<u1:p></u1:p><o:p></o:p>


    <o:p></o:p>


    Friday, January 04, 2013 9:41 PM
    Owner
  • 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,

      Hubert

    Sunday, April 14, 2013 2:58 PM