Overview of Simple Parallel Programming with .NET 4.0
Today’s modern day computers contain multi-core hardware capable of performing multiple tasks simultaneously, also known as parallel processing. Prior to .Net 4.0 the norm was to use synchronous operations to perform multi-threading. Although some level of synchronization logic is needed for data that is shared, the simple .NET 4.0 multi-threading technique presented in this article is excellent for scenarios when you have large data and do not have shared dependencies between the data.
To use the parallel feature in .NET 4.0 you need to use the namespace System.Threading.Tasks. Then you simply take the list structure that you want to traverse and iterate through it using Parallel.ForEach(IEnumerable<TSource> source, Action<TSource> body). For example,
Parallel.ForEach(someLargeList, item =>
For information on synchronized parallel programming, take a look at http://reedcopsey.com/2010/01/22/parallelism-in-net-part-4-imperative-data-parallelism-aggregation/. The author goes over how you can synchronize dependent data using the .NET 4.0 multithreading feature.