PrepAway - Latest Free Exam Questions & Answers

You need to ensure that the second operation is invoked only if the data processing operation throws an unhand

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?

PrepAway - Latest Free Exam Questions & Answers

A.
Create a task within the operation, and set the Task.StartOnError property to true.

B.
Create a TaskFactory object and call the ContinueWhenAll() method of the object.

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

D.
Use the TaskScheduler class to create a task and call the TryExecuteTask() method on the class.

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

3 Comments on “You need to ensure that the second operation is invoked only if the data processing operation throws an unhand

  1. m4r says:

    why after question says:
    You need to ensure that the second operation is invoked ONLY if the data processing operation
    throws an unhandled exception.
    correct answer is Task.ContinueWith when
    “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…”




    0



    0

Leave a Reply