Advantage of using async
The async actions are useful only when you are performing I/O bound operations such as remote server calls. The benefit of the async call is that during the I/O operation, no ASP.NET worker thread is being used.
So here’s how the first call works:
- When a request hits the action, ASP.NET takes a thread from the thread pool and starts executing it. Then method is invoked, during the entire call the worker thread is being risk.
The second call works:
- When a request hits the action, ASP.NET takes a thread from the thread pool and starts executing it, And returns immediately. An I/O Completion Port is registered and the ASP.NET worker thread is released to the thread pool.
- Later when the operation completes, the I/O Completion port is signaled, another thread is drawn from the thread pool to finish returning the view.
As you can see in the second case ASP.NET worker threads are used only for a short period of time. This means that there are more threads available in the pool for serving other requests. use async actions only when you have a true async API inside.