You need to ensure that the second operation is invoked…

You use the Task.Run() method to launch a long-running data processing operation. The data processing
operation often fails in times of heavy network congestion. If the data processing operation fails, a second
operation must clean up any results of the first operation. You need to ensure that the second operation is
invoked only if the data processing operation throws an unhandled exception. What should you do?

You use the Task.Run() method to launch a long-running data processing operation. The data processing
operation often fails in times of heavy network congestion. If the data processing operation fails, a second
operation must clean up any results of the first operation. You need to ensure that the second operation is
invoked only if the data processing operation throws an unhandled exception. What should you do?

A.
Create a TaskCompletionSource<T> object and call the TrySetException() method of the object.

B.
Create a task by calling the Task.ContinueWith() method

C.
Examine the Task.Status property immediately after the call to the Task.Run() method.

D.
Create a task inside the existing Task.Run() method by using the AttachedToParent option.

Explanation:
Task.ContinueWith – Creates a continuation that executes asynchronously when the target Task
completes.The returned Task will not be scheduled for execution until the current task has completed, whether
it completes due to running to completion successfully, faulting due to an unhandled exception, or exiting out
early due to being canceled. http://msdn.microsoft.com/en-us/library/dd270696.aspx



Leave a Reply 0

Your email address will not be published. Required fields are marked *