PrepAway - Latest Free Exam Questions & Answers

Which three actions should you perform in sequence?

DRAG DROP
You are developing a Windows Store app.
The following code is provided as part of an RSS feed reader.

You need to create an asynchronous method that reports progress and allows cancellation.
Which three actions should you perform in sequence? (To answer, move the appropriate actions
from the list of actions to the answer area and arrange them in the correct order.)

PrepAway - Latest Free Exam Questions & Answers

Answer: See the explanation

Explanation:
Box 1:

Box 2:

Box 3:

Note:
* IAsyncOperationWithProgress<TResult, TProgress> interface
Represents an asynchronous operation that includes progress updates.
* AsyncInfo.Run<TResult, TProgress> Method (Func<CancellationToken, IProgress<TProgress>,
Task<TResult>>)
Creates and starts a Windows Runtime asynchronous operation that includes progress updates, by
using a function that generates a started task that returns results. The task can support cancellation
and progress reporting.
* Example:
The AsyncInfo class is there to assist you with performing asynchronous actions or operations that
support cancellation and reporting progress.
public static IAsyncOperationWithProgress<int, double> Multiply(int a, int b)
{
return AsyncInfo.Run<IList<long>, double>((token, progress) =>
Task.Run<int>(() =>
{
progress.Report(0);
var result = a*b;
token.ThrowIfCancellationRequested();
progress.Report(100.0);
return result;

}, token));
}
http://msdn.microsoft.com/en-us/library/windows/apps/br206594.aspx
http://msdn.microsoft.com/en-us/library/hh779740(v=vs.110).aspx


Leave a Reply