title: How to block an operation until a condition is met?
body: <p>I am running this code and it is using a fair amount of CPU even though it is doing absolutely nothing most of the time.</p>
  
  <pre><code>while (this.IsListening)
  {
      while (this.RecievedMessageBuffer.Count &gt; 0)
      {
          lock (this.RecievedMessageBuffer)
          {
              this.RecievedMessageBuffer[0].Reconstruct();
              this.RecievedMessageBuffer[0].HandleMessage(messageHandler);
              this.RecievedMessageBuffer.RemoveAt(0);
          }
      }
  }
  </code></pre>
  
  <p>What is the best way to block until a condition is met?</p>