Click here to Skip to main content
15,881,763 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi
Please tell me what's the difference between Thread , Asynchronous Programming and Parallel.

Programming in c#.

Thank you
Posted
Updated 30-Sep-12 9:48am
v2

The .NET Framework provides several ways for you to use multiple threads of execution to keep your application responsive to your user while maximizing the performance of your user's computer.

Parallel programming model is to Parallelize your code to distribute work across multiple processors WHEREAS In an asynchronous process, the application can continue with other work that doesn't depend on the web resource until the potentially blocking task finishes.

Refer here for details: MSDN: Parallel Processing and Concurrency in the .NET Framework[^]
 
Share this answer
 
Comments
Sander Rossel 30-Sep-12 5:49am    
Good answer and nice link, my 5.
Sandeep Mewara 30-Sep-12 5:50am    
Ah. Thanks Naerling. :)
A Thread is a means to Async and Parallel programming. The real question is what is the difference between Async and Parallel programming.
Here's a blog[^] that explains it pretty well.
Here's the short of it:
Both Async and Parallel programming are methods to run code without blocking your UI (or main) thread
When you're programming Async you execute code on a different thread which prevents the UI from becoming unresponsive.
When you're doing Parallel programming you're doing multiple things at the same time. For example, you want to read all the files in a single folder on your file system. You could spawn a new thread for each file, which is theoretically faster than reading one file after another.
To illustrate the difference, in Async programming you could have the files being read one after another (so not parallel), but still do this on a different thread, so your UI stays responsive.
Also notice that the two are not mutually exclusive. You could spawn a thread to read the files (Async) and then read an x amount of files at the same time (Parallel).
I hope that clears things up for you :)
 
Share this answer
 
Comments
Sandeep Mewara 30-Sep-12 5:50am    
Good answer. My 5! :)
Sander Rossel 30-Sep-12 5:52am    
Thank you :)
Sergey Alexandrovich Kryukov 30-Sep-12 10:49am    
My 5. "The real question is" is a write approach. The OP's question is like "what's the difference between "Titanic" and "navigation"", not answerable. I tried to explain it in my answer, please see.
--SA
You need to solve completely different problem first. This is about your skills to ask correct question. This question is totally incorrect. I feel awkward to explain such elementary things, but please look at my past answer:
what is the difference between the class and encapsulation in programming[^].

Please see also this discussion:
How to ask a good question?[^].

Did you follow these directions for asking questions?

Code Project Questions and Answers FAQ[^]
How to Use Google and Other Tips for Finding Programming Help[^]
Some guidelines for posting questions in the forums[^].

Please, read them before you proceed.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900