You can combine the capabilities of the .NET Framework and the Windows Runtime to maximize your resources. The example in this topic uses .NET Framework features to add a cancellation button to an application that downloads blog feeds from the web by using a Windows Runtime API. This sample contains the example from Bridging between the .NET Framework and the Windows Runtime: Cancellation.
The code performs the following steps that enable you to use the .NET Framework cancellation feature in a Windows Store app.
Apply SyndicationClient.RetrieveFeedAsync to a URI to start an asynchronous operation that downloads a blog feed from the specified URI. The asynchronous operation is an IAsyncOperationWithProgress instance.
Because you want to take advantage of the cancellation capabilities that the .NET Framework offers, apply AsTask to represent the IAsyncOperationWithProgress instance as a Task<TResult>. In particular, apply an AsTask overload that accepts a CancellationToken argument.
Await the task to retrieve the SyndicationFeed result.
For more information about AsTask, see Extending the Starter Code in Bridging between the .NET Framework and the Windows Runtime: WhenAny (C# and Visual Basic).
You must have Windows 8 installed on your computer to run this sample.
To download the sample:
Run the code several times to verify that you can cancel at different points.