From the course: Threading in C#

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Tasks with continuation

Tasks with continuation - C# Tutorial

From the course: Threading in C#

Start my 1-month free trial

Tasks with continuation

- [Instructor] There are times when we want to execute some logic right after a task is completed. It's more like having an antecedent task passing on execution to a continuation task. Traditionally, we use callbacks for such a situation. However, in the task parallel library, the same functionality is provided by continuation tasks. A continuation is an asynchronous task that is invoked by another task, which is known as the antecedent, when the antecedent finishes. Chaining tasks via continuation is very easy to implement. They're very powerful and flexible to use. For example, you can pass data from the antecedent to the continuation task. Not only that, you can also pass exceptions to the continuation and let the continuation task handle the exception there. You can also specify the precise conditions under which the continuation will be invoked. If, for some reasons, under certain conditions you don't want to invoke the continuation, you have the power to specify that too. You…

Contents