الاثنين، 6 سبتمبر 2010

Parallel LINQ .. Small change.. Great impact

In the Name of Allah the most gracious the most merciful

Parallel LINQ .. Small change.. Great impact

Peace be with you All

If you had use Linq before in the last two versions in .Net Framework, it will be great because we will ask you to make small change to your Linq code to be Parallel Linq !

Yes it is small change but with great impact, now in .Net Framework 4 you can make use of the Parallel Computing by adding .AsParallel() only to the Linq query.

When your application run on multi core computer, you must use the power of code to get best performance.

As in the following example:

var x = from c in Customers.AsParallel()

        where c.FName == y.FName &&

              c.LName == y.LName

        orderby c.age ascending

        select c;

when you read this code again you will found no change except the AsParallel Function it will increase the performance of the code execution .. So use it :)

I hope it was helpful info for you

Good Luck with Visual Studio 2010

Ahmed Fawzy