My goal is increase scalability of a Web API I am working on. To that end, I've implemented the controller actions to be async
. The idea being that request threads are released and are available to handle other incoming requests. However, the winning answer of Effectively use async/await with ASP.NET Web API
states:
You'd need a truly asynchronous implementation to get the scalability benefits of async.
Eventually my code needs to call a method from a 3rd party library that is very synchronous, single threaded and I/O bound. So really the only way to do it is through Task.Run()
, which I am assuming will hold on to the thread - thereby cancelling the benefits of async/await.
So is there a way to realize the benefits of async/await in a Web API scenario when there is a synchronous operation in the mix?