Is there support for the async/await pattern in WP8?
I need to get XML from a web-based API and it looks like that WebClient or WebRequest
I had the same issue and I found this and helped me
private async Task ExecuteAsync(RestRequest request)
{
var tcs = new TaskCompletionSource();
_client.ExecuteAsync(request, resp =>
{
var value = JsonConvert.DeserializeObject(resp.Content);
if (value.ErrorCode > 0)
{
var ex = new ToodledoException(value.ErrorCode, value.ErrorDesc);
tcs.SetException(ex);
}
else
tcs.SetResult(value);
});
return await tcs.Task;
}
http://www.developer.nokia.com/Community/Wiki/Asynchronous_Programming_For_Windows_Phone_8 also I found this extension helpful http://nuget.org/packages/WP8AsyncWebClient/