As Cleary wrote in his post, in order to create an asynchronous call your task should be awaited too. That means, the method in your question (MakeCall()
) is asynchronous but probably the call to the method is synchronous.
An asynchronous example class:
using System.Threading.Tasks;
public class SampleClass
{
public async Task<string> MakeCall()
{
# I am using the asynchronous call from the HttpClient library
var response = await client.PostAsJsonAsync(url, creds)
...
}
}
Try to await the call to the method.
var makeCall = await SampleClass.MakeCall();
What I would avoid is using .Result
. As JDandChips already implies, it makes your call again synchronous. In this case, however, there is no need to try to make is asynchronous in the first place.