title: Infinite while loop in TAP example
body: <p>While researching the TAP (Task-based Asynchronous Pattern), I found this example snippet on this MSDN <a href="https://msdn.microsoft.com/en-us/library/hh873173(v=vs.110).aspx" rel="nofollow">webpage</a>. </p>
  
  <pre><code>private static AsyncProducerConsumerCollection&lt;int&gt; m_data = …;
  …
  private static async  Task ConsumerAsync()
  {
      while(true)
      {
          int nextItem = await m_data.Take();
          ProcessNextItem(nextItem);
      }
  }
  …
  private static void Produce(int data)
  {
      m_data.Add(data);
  }
  </code></pre>
  
  <p>I don't think it makes sense as this is really an infinite loop with no way out. Am I missing something? If so, appreciate some explanation on how it works.</p>
  
  <p>EDIT: I get the scope of the example, that function is trying to process items until it runs out. I also get that <code>Task</code> is same as <code>Task&lt;void&gt;</code>, i.e., this function doesn't have to return anything. But the fact that it has a <code>while(true)</code> bothers me, since this means this function runs forever. Does this mean it is upto the calling function to terminate the application? The details of this part is not so clear to me.</p>