In WFA, double buffering slows performance without completely eliminating flickering in custom graphics areas. For built-in GUI elements, for example, if you create a game created from ImageButtons and Labels, the double-buffered built-in mode perfectly hides the redrawing of the control tree. However, there are several serious issues with using it for a custom drawing area:
- The drawing buffer created when you set up the application to create double buffering is used to draw the entire window and all child controls, not just your custom drawing area, so you add the overhead of redrawing each GUI element to the back buffer before dragging the page.
- If something invalidates the control, the Paint method is called. You cannot finish drawing when this happens, and you will get an incomplete image shown to the user (not very good in real time).
By preserving the GUI base window with one buffer, but creating an area in which you control buffering, both of these problems are minimized.
Double buffering methods can be as simple as creating a Bitmap object as the back buffer and drawing it in the drawing area when you are good and ready, or creating a separate BufferedGraphicsContext to control the buffering of your custom drawing area.
Keiths
source share