I am trying to see what difference does adding async to a method which returns a task make.
Method in controller:
public async Task<IHttpActionResult> GetSomeData()
{
var result = await _myService.GetAString();
return Ok(result);
}
In MyService:
public Task<String> GetAString()
{
return _repository.GetAStringAsync();
}
In repository:
public async Task<String>GetAStringAsync()
{
return await ......configureawait(false)
}
Adding async await to the Service method works just fine. But what is the difference between these two service methods then? The only difference I can spot is that using version 2 I can use configureAwait(false)
**In MyService: ( cannot use configureawait)**
public Task<String> GetAString()
{
return _repository.GetAStringAsync();
}
And
In MyService: (can use configure await)
public async Task<String> GetAString()
{
return await _repository.GetAStringAsync();
}
Thanks