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 B

C.
Option C

D.
Option D



Leave a Reply 9

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


Iron

Iron

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.

Francisco Lacerda

Francisco Lacerda

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…

qwe

qwe

Difference between A and D is in ReadAsAsync and ReadAsAsync.

qwe

qwe

JsonArray vs JsonObject

Syed Ajaz Akhter

Syed Ajaz Akhter

Correct – A