O'Reilly logo

C# Multithreaded and Parallel Programming by Rodney Ringler

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Task exception handling

Well, we have learned how to start, coordinate, and cancel tasks. Now, let's talk about error handling with tasks. In C#, when we discuss error handling, we are really talking about the try..catch..finally structure. In this book, we assume you are familiar with the operation of a try..catch block.

A task has a lifecycle of states that it can be in. A task can be idle (scheduled), running, pending, cancelled, faulted, or completed. Each task has a status property that defines the current state of the task. We saw this in the last section and used OnlyOnCanceled and OnlyOnRanToCompletion as the options for TaskContinuationOptions for our ContinueWith methods.

So, when we talk about exception handling with TPL, we are referring ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required