Unable to Service Request

Unable to Service Request

For the latest headlines and to see what's new, visit the MSDN home page.

Check out the various MSDN Developer Centers where you can find the latest product information, technical resources, and community offerings.

Visit the MSDN Library for the latest technical articles, reference documentation, downloads, and more.
© 2013 Microsoft. All rights reserved.
What is the effect of PropigateCompletion on a BroadcastBlock

Answered What is the effect of PropigateCompletion on a BroadcastBlock

  • Sonntag, 22. April 2012 06:12
     
     

    When I have a single TargetBlock linked to a BroadcastBlock, the PropigateCompletion tag seems to work as expected.

    However, when I attach 2 TargetBlocks it doesn't seem to to propigate correctly.



    Brad Serbu

Alle Antworten

  • Sonntag, 22. April 2012 13:15
     
      Enthält Code

    It seems to work fine to me. You should post the code you're using, describe what it does and what you would expect it to do.

    In the following code, the completion propagates correctly to both targets for me:

    var buffer = new BufferBlock<int>();
    
    var target1 = new ActionBlock<int>(i => Console.WriteLine("Target 1: {0}", i));
    var target2 = new ActionBlock<int>(i => Console.WriteLine("Target 2: {0}", i));
    
    buffer.LinkTo(target1, new DataflowLinkOptions { PropagateCompletion = true });
    buffer.LinkTo(target2, new DataflowLinkOptions { PropagateCompletion = true });
    
    buffer.Post(1);
    buffer.Post(2);
    
    buffer.Complete();
    
    Task.WaitAll(target1.Completion, target2.Completion);
  • Sonntag, 22. April 2012 16:59
     
     Beantwortet

    It was my understanding of your code above that target2 would likely not get any messages, as target1 would greedly take all items.

    Changing your BufferBlock<T> to a BroadcastBloc<T, T> was what I was attempting.  In that case target2 does process messages, but it didn't seem to complete in my code.

    This was my fault and I found my bug.


    Brad Serbu

Unable to Service Request

Unable to Service Request

For the latest headlines and to see what's new, visit the MSDN home page.

Check out the various MSDN Developer Centers where you can find the latest product information, technical resources, and community offerings.

Visit the MSDN Library for the latest technical articles, reference documentation, downloads, and more.
© 2013 Microsoft. All rights reserved.