title: Alternative to an infinite loop
body: <p>I have an infinite loop:-</p>
  
  <pre><code>while(true)
  {
  //display an image
  }
  </code></pre>
  
  <p>Obviously the CPU goes up.</p>
  
  <p>I have used:</p>
  
  <pre><code>Thread.Sleep(100);
  Thread.Sleep(0);
  ApplicationDoEvents() - I know i shouldn't
  </code></pre>
  
  <p>This loop will never end unless the application is ended.  Are they any other alternatives to an infinite loop?</p>
  
  <p>I am displaying the image in a usercontrol and I am overriding the <code>OnPaint</code> event...</p>
  
  <pre><code>if (CurrentFrame != null)
  {
      g.DrawImageUnscaled(CurrentFrame, 0,0);
  }
  
  
  
  public void NewFrame(Image _currentFrame)
  {
      if (CurrentFrame != null)
      {
          CurrentFrame.Dispose();
      }
      CurrentFrame = _currentFrame;
      Invalidate();
      //Update();  
  }
  </code></pre>
  
  <p>Any insights/suggestions/recommendations would be most welcome... </p>