A common thing that’s done once a task is complete is to update the UI.  However, one thing to keep in mind is to make sure you also update the UI if the task doesn’t complete successful for whatever reason.  This is actually easy to do with the Task Parallel Library (TPL) using the ContinueWith and TaskContinuationOptions enumeration. The below code handles updating the UI by writing a status message when the task completes successfully.

The following code updates the UI when the task has failed for some reason with the exception that was thrown in the task.


Like this post? Share it!