Created
November 25, 2014 22:06
-
-
Save avanderhoorn/08b792b1626bf4e5aba8 to your computer and use it in GitHub Desktop.
HttpClient test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_httpClient.GetAsync("http://localhost:15316/Glimpse/Agent") | |
.ContinueWith(requestTask => | |
{ | |
// Get HTTP response from completed task. | |
HttpResponseMessage response = requestTask.Result; | |
// Check that response was successful or throw exception | |
response.EnsureSuccessStatusCode(); | |
// Read response asynchronously as JsonValue and write out top facts for each country | |
response.Content.ReadAsAsync<string>().ContinueWith(readTask => | |
{ | |
var result = readTask.Result; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For connection failures, disconnects, timeouts and cancellations you have to do a try/catch around the GetAsync method.