Probably you’ve already heard of it, multi-threading. Multi-threading is an efficient way to do multiple things at once. This way you can for example speed up the loading process of a game or other app because the code doesn’t necessarily run line by line but can do multiple things at once.

In the sample that I prepared I’m going to draw circles, it’s a very simple yet clear way to get to know ‘threads’.

First you have to create a Windows Forms C# application.
1

Without threads the code will run line by line, you first press the red button to start drawing the red circles, when that’s done you’ll have to press the green button to draw the green circles. In other words, first the red circles will be drawn and when that’s done the green circles.

With threads it works different, now we can draw red and green circles simultaneously. When you look at the following code you can see how it works.

When you run the code you will the following output:

You see, code can be art too :)

You see, code can be art too 🙂


You can download the project files here.

I also prepared a version that doesn’t use threads to show you the difference, you can download it here.