I’m facing a strange problem. Below are 3 code variants:
Variant 1 (working)
private static HttpResponseMessage executeAsync()
{
var reguest = getRequest(jsonRequest, HttpMethod.Post);
var response = client.Send(reguest);
return response;
}
Variant 3 (working)
private static async Task<HttpResponseMessage> executeAsync()
{
var reguest = getRequest(jsonRequest, HttpMethod.Post);
var response = client.SendAsync(reguest).Result;
return response;
}
Variant 3 (doesn’t work!)
private static async Task<HttpResponseMessage> executeAsync()
{
var reguest = getRequest(jsonRequest, HttpMethod.Post);
var response = await client.SendAsync(reguest);
return response; // The execution doesn't reach this line
}
I rarely use asynchronous operations, and therefore I can’t figure out what’s wrong here.
Can somebody explain to me?