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 B
C.
Option C
D.
Option D
Should be A
agree
agree
A
Please good people, explain or support your answers of choice every time. If you don’t, you leave us in the middle of the jungle.
Just a synopsis of why it is not the answer and/or why it is the answer.
Everything from Task that has the .Result is synchronous operationand blocks the calling thread:
“Accessing the property’s get accessor blocks the calling thread until the asynchronous operation is complete; it is equivalent to calling the Wait method.”
https://msdn.microsoft.com/en-us/library/dd321468(v=vs.110).aspx
So B and C are wrong.
Still, I am unable to see any diference between A and D…
Difference between A and D is in ReadAsAsync and ReadAsAsync.
JsonArray vs JsonObject
Correct – A