I am getting confused as asynchronous programming is a way to execute a block of code asynchronously, that calls a method and doesn’t wait for the result. In the same way, parallel programming is a way to execute more than one task simultaneously, but all those tasks are executed asynchronously. So wondering/confused what is the relationship between these two programming paradigms in c#.
Share
Parallel programming is a technique where we use multiple threads to execute a task faster. This means that on modern multi-core architectures we can utilize more of the resources available to perform a task.
A great example of this is sorting a list using quicksort.
Normally with parallel programming, performance is important and all the threads are working to a common goal.
Asynchronous programming is subtly different. This normally involves longer running tasks and tasks which are perhaps waiting on some kind of external stimuli. A good example of this is to perform a large calculation in a background thread so that the UI remains responsive. With asynchronous code we are normally talking about code which executes at a different rate to our main application.