Exemplo n.º 1
0
 public Task <string> GetStringAsync(Uri requestUri)
 {
     return(GetAsync(requestUri, HttpCompletionOption.ResponseContentRead).ContinueWith(t =>
     {
         HttpResponseMessage r = t.GetAwaiter().GetResult();
         r.EnsureSuccessStatusCode();
         HttpContent c = r.Content;
         return c != null ? c.ReadBufferedContentAsString() : string.Empty;
     }, CancellationToken.None, TaskContinuationOptions.ExecuteSynchronously | TaskContinuationOptions.DenyChildAttach, TaskScheduler.Default));
 }