Parallel Articles

Protect Data on Multiple Processes using C#

If you have a routine which splits data across processors using the Parallel class you may need to protect memory, files or other resources which are shared across the multiple processes. One solution to this is to use a mutex, which is similar to a Monitor object, but at the operating system level. Mutexes must […]

Read more

Using the Parallel Class in C# – Run Tasks in Parallel on Multiple Processors or Cores

The Parallel Class can be used to split up the tasks which work on the data. For example if you have iterative code that looks like the below code: //6 parts of the book string[] inputTextFiles = { “part1.txt”, “part2.txt”, “part3.txt”, “part4.txt”, “part5.txt”, “part6.txt” }; foreach (string file in inputTextFiles) { string contentStr = File.ReadAllText(file); CountCharacters(contentStr); […]

Read more

Using the Parallel Class in C# – Processing Data in Parallel across Multiple Processors or Cores

The new Task Parallel Library introduced with .NET 4, allows you to easily split code execution onto multiple processors without using threads or locks. For a task which is easily split into independent sub-tasks, or data that can be partitioned and computed separately you can use the Parallel class in System.Threading to assign tasks to […]

Read more