Using .Net 4 Parallel programming to speed up ForEach loops.

Background

Multi core processors started to become common place in consumer pc’s in 2006 with the introduction of Core Duo processors. These days its commonplace for even budget pc systems to have 4 or more cores with an i5 processor or up to 8 with an i7 processor.   In a server environment such as those hosting websites it’s possible to increase this even more with companies such as Dell offering 64 core servers.

A computer with multiple cores is capable of running several tasks in parallel, as opposed to waiting for a task to complete before running the next task. The problem is that traditional programming methods in languages such as c# don’t take advantage of these multiple cores and tend to run tasks in turn on one core while leaving the other cores idle.

This post will show the advantages, and potential disadvantages of one simple method to speed up a common programming loop.

Read More »

Advertisements