title: SpinWait vs Sleep waiting. Which one to use?
body: <p>Is it efficient to </p>
  
  <pre><code>SpinWait.SpinUntil(() =&gt; myPredicate(), 10000)
  </code></pre>
  
  <p>for a timeout of 10000ms </p>
  
  <p>or </p>
  
  <p>Is it more efficient to use <code>Thread.Sleep</code> polling for the same condition 
  For example something along the lines of the following <code>SleepWait</code> function:</p>
  
  <pre><code>public bool SleepWait(int timeOut)
  {
      Stopwatch stopwatch = new Stopwatch(); 
      stopwatch.Start();
      while (!myPredicate() &amp;&amp; stopwatch.ElapsedMilliseconds &lt; timeOut)
      {
         Thread.Sleep(50)
      }  
      return myPredicate()
  }
  </code></pre>
  
  <p>I'm concerned that all the yielding of SpinWait may not be a good usage pattern if we are talking about timeouts over 1sec? Is this a valid assumption? </p>
  
  <p>Which approach do you prefer and why? Is there another even better approach?</p>
  
  <hr>
  
  <p><strong>Update</strong> - Becoming more specific: </p>
  
  <p>Is there a way to Make BlockingCollection Pulse a sleeping thread when it reaches bounded capacity? I rather avoid a busy waits alltogether as Marc Gravel suggests. </p>