Which code segment should you use?

You are developing a .NET application that uses the HttpClient type to call an ASP.NET Web API
application. The API call returns a list of customers in JSON format and logs the results.The URI for the API call is in a variable named address.
You need to make the API call without blocking.
Which code segment should you use?

You are developing a .NET application that uses the HttpClient type to call an ASP.NET Web API
application. The API call returns a list of customers in JSON format and logs the results.The URI for the API call is in a variable named address.
You need to make the API call without blocking.
Which code segment should you use?

A.
Option A

B.
Option BC. Option C

D.
Option D

Explanation:
Example:
// Create an HttpClient instance
11: HttpClient client = new HttpClient();
12:
13: // Send a request asynchronously continue when complete
14: client.GetAsync(_address).ContinueWith(
15: (requestTask) =>
16: {
17: // Get HTTP response from completed task.
18: HttpResponseMessage response = requestTask.Result;
19:
20: // Check that response was successful or throw exception
21: response.EnsureSuccessStatusCode();
22:
23: // Read response asynchronously as JsonValue and write out top facts for each country
24: response.Content.ReadAsAsync<JsonArray>().ContinueWith(
25: (readTask) =>



Leave a Reply 0

Your email address will not be published. Required fields are marked *