I am working on a Windows Phone 8.1 project. There are two versions of http client in Windows 8.1 - system.net.http
and windows.web.http
. Microsoft re
Haven't tested it yet, but this could work:
await client.GetStringAsync(new Uri("http://www.google.com")).AsTask(cancellationToken);
If you don't have the need for cancellation tokens, you can also cancel the IAsyncOperation directly like this:
var operation = _httpClient.GetStringAsync(new Uri("http://www.google.com"));
var response = await operation;
operation.Cancel();
This blog post is a good read on the whole Task vs IAsyncOperation topic.