title: Why is my ActionBlock not executed when my BroadcastBlock posts?
body: <p>I am trying to understand <a href="https://docs.microsoft.com/en-us/dotnet/standard/parallel-programming/dataflow-task-parallel-library" rel="nofollow noreferrer">Dataflow</a> in C#, so I wrote a fiddle <a href="https://dotnetfiddle.net/7hLNBC" rel="nofollow noreferrer">here</a> and I'm curious why my action blocks are not executing in my example.</p>
  <pre><code>using System;
  using System.Linq;
  using System.Threading;
  using System.Threading.Tasks;
  using System.Threading.Tasks.Dataflow;
  
  public class Program
  {
      public static void Main(string[] args)
      {
          var numberOfProducers = 1;
          var numberOfConsumers = 10;
          
          var allProducers = Enumerable.Range(0, numberOfProducers).Select(x =&gt; new BroadcastBlock&lt;double&gt;(d =&gt;
              {
                  return d;
              },
              new DataflowBlockOptions()
              {
                  BoundedCapacity = 500
              }));
          
          var allConsumers = Enumerable.Range(0, numberOfConsumers).Select(x =&gt; new ActionBlock&lt;double&gt;(d =&gt;
              {
                  Console.WriteLine(String.Format(&quot;Consuming {0} on Thread ID: {1}&quot;, d, Thread.CurrentThread.ManagedThreadId));
              },
              new ExecutionDataflowBlockOptions()
              {
                  BoundedCapacity = 500
              }));
          
          foreach (var producer in allProducers)
          {
              foreach (var consumer in allConsumers)
              {
                  producer.LinkTo(consumer);
              }
          }
  
          Parallel.For(0, 20, (i) =&gt;
          {
              foreach (var producer in allProducers)
              {
                  Console.WriteLine(String.Format(&quot;Posting {0} on Thread ID: {1}&quot;, i, Thread.CurrentThread.ManagedThreadId));
                  producer.Post(i);
              }
          }
  
          );
      }
  }
  </code></pre>
  <p>An example of output from this program is as follows</p>
  <blockquote>
  <p>Posting 0 on Thread ID: 18</p>
  <p>Posting 10 on Thread ID: 16</p>
  <p>Posting 1 on Thread ID: 17</p>
  <p>Posting 11 on Thread ID: 19</p>
  <p>Posting 2 on Thread ID: 18</p>
  <p>Posting 4 on Thread ID: 17</p>
  <p>Posting 5 on Thread ID: 17</p>
  <p>Posting 6 on Thread ID: 17</p>
  <p>Posting 3 on Thread ID: 18</p>
  <p>Posting 12 on Thread ID: 18</p>
  <p>Posting 7 on Thread ID: 17</p>
  <p>Posting 16 on Thread ID: 19</p>
  <p>Posting 8 on Thread ID: 17</p>
  <p>Posting 17 on Thread ID: 19</p>
  <p>Posting 9 on Thread ID: 17</p>
  <p>Posting 18 on Thread ID: 19</p>
  <p>Posting 19 on Thread ID: 19</p>
  <p>Posting 13 on Thread ID: 18</p>
  <p>Posting 14 on Thread ID: 18</p>
  <p>Posting 15 on Thread ID: 18</p>
  </blockquote>
  <p>I would expect there to be several lines mixed in showing the action blocks consuming the data being posted on the broadcast block.</p>