Waiting for multiple tasks to complete

In the previous section, we examined how to explicitly and implicitly wait on a task to complete. Now, let's see how we can control execution and waiting when we start many tasks instead of just one.

Sometimes, we may want to wait on one task out of a group to finish. Sometimes, we might want to wait on all of the tasks to finish, and other times we might want to wait on a certain condition of tasks to finish before proceeding.

The following screenshot shows all of the Wait and When methods provided with the Task class. The Wait methods are as shown:

Waiting for multiple tasks to complete

The When methods are as shown:

Both images are references from ...

Get C# Multithreaded and Parallel Programming now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.