title: What is the proper way to take an item from a BlockingCollection?
body: <p>When calling BlockingCollection.Take() it is possible for the IsCompleted status of the collection to change between the check of IsCompleted and the call to Take().</p>
  
  <p>The <a href="http://msdn.microsoft.com/en-us/library/dd997371.aspx" rel="noreferrer">MSDN Documentation</a> that shows an example just catches the invalid operation exception, but it seems like there must be a proper way to do such a call without catching the exception (since this incurs a decent amount of overhead and doesn't look clean in code).  What is the proper way to call .Take() and to avoid an invalid operation exception?</p>
  
  <p>A simplified version of my specific issue:</p>
  
  <pre><code>If (!blockingCollection.IsCompleted)
  {
  //do some stuff
  value = blockingCollection.Take();  //Throws Exception, IsCompleted = True;
  }
  </code></pre>
  
  <p>There is a TryTake method available, but I am under the impression that it is so that a timeout and cancelation token can be passed in, not to deal with the IsCompleted becoming true in between the time it is checked and when Take() is called.</p>