Is Async await Actually a blocking call?

Viewed 198
private async Task<string> GetStateInfo()
{
   var cityId = await GetCityIdByNameAsync("Delhi");
   var state = await GetStateNameAsync(cityId);
   return state;
}

As we know async and await are used for asynchronous programing and they are for non-blocking programming model. But in the code above the var state = await GetStateNameAsync(cityId); executes when the 1st line executes as it takes input from that. So I dont understand is it a blocking call or non-blocking call?

1 Answers

Please see my async intro. await is an "asynchronous wait", so it "pauses" the method and returns an incomplete Task<string> instance. So the method is waiting for the task returned by GetCityIdByNameAsync to complete, but there is no thread blocked waiting for it.

Related