title: Equivalent of do() while{} in Parallel
body: <p>How can I create the parallel equivalent of a <code>do</code>-<code>while</code> or similar in the <code>Update()</code> method below?</p>
  
  <p>Another thread in the app writes to <code>TestBuffer</code> at random. <code>TestBuffer.RemoveItemAndDoSomethingWithIt();</code> should run until the <code>TestBuffer</code> is empty. Currently <code>Update()</code> only runs with the items that were in the collection when it was was enumerated, which makes sense.</p>
  
  <pre><code>internal class UnOrderedBuffer&lt;T&gt; where T : class
  {
      ConcurrentBag&lt;T&gt; GenericBag = new ConcurrentBag&lt;T&gt;();
  }
  
  internal class Tester
  {
      private UnOrderedBuffer&lt;Data&gt; TestBuffer;
  
      public void Update()
      {
          Parallel.ForEach(TestBuffer, Item =&gt;
          {
              TestBuffer.RemoveItemAndDoSomethingWithIt();
          });
      }
  }
  </code></pre>