title: Concurrent collections eating too much cpu without Thread.Sleep
body: <p><strong>What would be the correct usage of either, <code>BlockingCollection</code> or <code>ConcurrentQueue</code> so you can freely dequeue items without burning out half or more of your CPU using a thread ?</strong></p>
  
  <p>I was running some tests using 2 threads and unless I had a Thread.Sleep of at least 50~100ms it would always hit at least 50% of my CPU.</p>
  
  <p>Here is a fictional example:</p>
  
  <pre><code>private void _DequeueItem()
  {
      object o = null;
      while(socket.Connected)
      {
          while (!listOfQueueItems.IsEmpty)
          {
              if (listOfQueueItems.TryDequeue(out o))
              {
                  // use the data
              }
          }
      }
  }
  </code></pre>
  
  <p>With the above example I would have to set a thread.sleep so the cpu doesnt blow up.</p>
  
  <p>Note: I have also tried it without the while for IsEmpty check, result was the same.</p>