Introducing DotNetFunda.com on mobile http://m.dotnetfunda.com ! Be with DotNetFunda.com on the go !
Go to DotNetFunda.com
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 7299 |  Welcome, Guest!   Register  Login
Home > Articles > C# > Parallel Compting in C# 4.0

Parallel Compting in C# 4.0

1 vote(s)
Rating: 5 out of 5
Article posted by Anup1252000 on 8/9/2010 | Views: 6003 | Category: C# | Level: Beginner red flag


In this article, you will see how to use Parallel Computing in c#

Download


 Download source code for Parallel Compting in C# 4.0


Introduction

Now days, hardware supports 2 core and 4 core processor that help multiple thread to be executed at a same time.
By using the advanced hardware, you can distribute your work across multiple processors simultaneously.

Architecture

Here is the Architecture of Parallel Computing. I took this diagram from the MSDN.

Reference: MSDN

Advantage and disadvantage of using Parallel computing:

Advantage

  • Suppose if you are running long method then you can send that particular method in the thread and you don’t
     need to wait until that method is executed.
  • Performance of the application is very fast.

Disadvantage

  • It’s a fire and forgets kind of mechanism. We don’t know when we get the result back. As per my knowledge its better to use in a dropdownlist. For example: In the long filling info such as Signup.

Here in this article I am working on VS2008. You can download Parallel Computing for VS 2008 here. Here in this article I am concentrating on PLINQ. For better understanding you first need to understand Parallel Enumerable Operators: 

Code Part:

In some of the cases I have used LINQ to SQL. Diagram will look like this

Here I am working on only one table called employee. First let’s work on simple query. Here we are using AsParallel() operator.

Here we will see how to use AsOrdered() operator.

Here we will see how to use AsSequential() operator.

Now lets understand, how to use Exceptional Handling in PLINQ. To Catch the exception in PLINQ we need to use AggregateException.

Here we will see how to cancel the excution using WithCancellation() operator.

Hope this article would have given a good insight of the basics of the Parallel computing. Keep learning and reading my forthcoming articles.

 

Reference

http://msdn.microsoft.com/en-us/library/dd460693.aspx

If you like this article, subscribe to our RSS Feed. You can also subscribe via email to our Interview Questions, Codes and Forums section.

Page copy protected against web site content infringement by Copyscape
Found interesting? Add this to:



Please Sign In to vote for this post.

About anup hosur

Experience:2 year(s)
Home page:
Member since:Saturday, August 01, 2009
Level:Starter
Status: [Member]
Biography:
>> Write Response - Respond to this post and get points
Related Posts

New advancements incorporated in the latest .Net Framework version 4, specifically for C# 4.0

This article describes basics about delegate and events and later shows how it can be used in project or real time scenario.

I just read about Extension methods so thought to write about it so as to give brief idea about this feature introduced in C# 3.0. Extension Methods:static methods that you can invoke using the instance method syntax.

This article describes about the use of Interface in C#.

How to validate a Cell Number in Windows foms

More ...
About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you found plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/21/2012 8:26:57 AM