I have come across a small issue, I have written a asp.net web api service and I automatically added "async" on the controller, of course this now requires that I use await.
The problem I have is that my controller is connected to a service layer and this service layer then connects to a data layer - this data layer is the layer that is calling an ASYNC version of GET to make an asynchronous call to another REST service - so this is easy, I can convert my data layer method to have an "async" keyword and i will place a await on the HttpClient GetSync call.
but my service layer to support async / await I need to change the return type to Task but the service layer really isn't doing anything ASYNC its calling to the data layer that is actually calling HttpClient async methods.
So I have 2 options considering I have the following layer structure.
ASP.NET Web Api >> Service Layer >> Data Layer
Only have async and await used in the Data Layer and be done with it.
Or place async and await on the controller and the method from the service layer, this requires refactoring as I need to return Task.
I suppose where I am not understanding it fully, technically the only blocking calls would be in the data layer, so to have all threads returned the thread pool for use I should only be concerned with placing async and await on the data layer ?
When would i need to use pattern on the controllers ???
Look forward to any help