Parallel delegate execution using Tasks
While implementing the logic for a new app our team is working on, one of my colleagues encountered the following problem:
He wanted to implement a method that had to perform a series of parallel web service calls and continue the execution of the method once all of the calls have completed. Since we make extended use of the async / await constructs we decided that we needed a helper method that could accept a series of delegates and that returned a Task.
The Task.WhenAll method accepts a series of tasks as input and returns a Task that is marked as completed once all of the tasks are completed.
The method creates a new Task for each provided delegate and passes this series of tasks to the WhenAll method. See the following example for usage:
Need to pass parameters to your actions? Use a lambda expression:











