O'Reilly logo

C# 2008 and 2005 Threaded Programming: Beginner's Guide by Gastón C. Hillar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating independent blocks of concurrent code

Processing an image using multiple threads is something difficult in .NET with C# because GDI+ instances are not prepared for multithreaded access. Nevertheless, we could create self-sufficient blocks of safe concurrent code dividing the image into many independent images and adding a results collector.

Note

This principle is the simplest way to transform a single-threaded algorithm into a multithreaded algorithm avoiding many complex problems related to concurrency.

Each thread works in its independent block, without disturbing or interfering with the other threads.

However, the code used for dividing the original bitmap dynamically into many smaller bitmaps is a bit complex. That is the price we have ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required