Double Buffering, It Works

Double buffering is something that has always bugged me, like databases and web programming, not because it’s complicated (at least in a high level language like C#) but because I didn’t understand it (the same happened with those other two things, until one year ago, and now I like them a lot).
It all started some days ago when I had an aha moment and got back to programming, this time a tag cloud control for the .NET framework. The problem was that when I resized the control, and in doing so the tag cloud, some horrible, terrible and annoying flickering of the labels inside of it took place.
I put off that part and keep working on other thing, until today when I decided something had to be done, so I straightened in my chair, took a deep breath, pulled up my sleeves and wrote in the control’s constructor:

this.DoubleBuffered = true;

And that was it, sayonara to the flickering. I must admit I just tested it with a small amount of data, but with that same amount of data and without double buffering, you had to look away while resizing the window because the flickering might leave you blind.

So what’s all this double buffering thing about? instead of outputting each control to the monitor everytime it has to be redrawn, the things that need to be refreshed are stored in the central memory for a little while and then batch-displayed.
Obviously, this explanation is oversimplified, so you know who to ask if you want to know more.
Wikipedia, we love you! :)

Anuncios

Responder

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión / Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión / Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión / Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión / Cambiar )

Conectando a %s

A %d blogueros les gusta esto: