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

Time for action - Creating an independent class to run in parallel without side effects

The best way to achieve a parallelized execution without problems is to create a class that contains all the code to be run concurrently in order to avoid undesired and problematic side effects. Yes, we will be using .NET Parallel Extensions, but that does not mean we have to forget about side effects and concurrency problems.

Now, you just have to create a class with independent code to be run in parallel using the .NET Parallel Extensions. Many instances of this class will be running in parallel according to the number of available cores.

You have to work in a very fast and very efficient blob counter that will be able to run concurrently and avoid side effects. ...

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