title: Windows forms: How to handle redrawing efficiently?
body: <p>I have a form with a picturebox which displays a picture and some overlay drawn in the Paint event handler of the picturebox. The overlay updates itslef (basically changes opacity of different parts of the overlay) based on mouse movement.</p>
  
  <p>Currently, I am calling <code>pictureBox.Invalidate()</code> from mouse moved handler to ensure that the overlay is repainted. I have also implemented some logic to determine whether the repaint is really needed - if no object changed its opacity with the mouse move, the <code>PictureBox</code> is not invalidated.</p>
  
  <p>I am still getting <b>50 percent CPU usage</b> on a dual core machine when I move the mouse faster than very slowly - I am guessing the painting routine just does not manage to repaint as often as the mouse moved events are generated.</p>
  
  <p>There are not many objects drawn, up to 10 filled rectangles with a 4 filled triangle corners each. The problem is there with a single overlay object already. Basically only <code>FillRectangle</code> and <code>FillArea</code> methods are used to perform the painting.</p>
  
  <p><b>What approach would you propose in this situation to prevent such high CPU usage?</b></p>