Tallan's Technology Blog

Tallan's Top Technologists Share Their Thoughts on Today's Technology Challenges

Overview of Simple Parallel Programming with .NET 4.0

Micael George

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 =>

{

doSomething();

});.

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.

Related Articles

The Cost of Reflection
WCF Security Part 1
Intro to PLINQ

No comments

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

\\\