× {{alert.msg}} Never ask again
Get notified about new tutorials RECEIVE NEW TUTORIALS

TPL Dataflow LinkTo only if no others match

Asad Saeeduddin
Oct 08, 2015
<p>As long as you prepend all your links after linking the <code>NullTarget</code>, they'll take precedence over the <code>NullTarget</code> block, and the message will be discarded only if it doesn't satisfy any of the predicates:</p> <pre><code>var forwarder = new BufferBlock&lt;SomeType&gt;(); forwarder.LinkTo(DataflowBlock.NullTarget&lt;SomeType&gt;()); // NullTarget is linked unconditionally //... Some other stuff happens // Dynamically linking new block so it takes precedence over the NullTarget forwarder.LinkTo(target1, new DataFlowLinkOptions() { Append = false }, matchesTarget1); </code></pre> <p>This tip was originally posted on <a href="http://stackoverflow.com/questions/29885258/TPL%20Dataflow%20LinkTo%20only%20if%20no%20others%20match/29885466">Stack Overflow</a>.</p>
comments powered by Disqus