Reputation: 3041
What is the mechanism behind async tasks in MVC 4? How is it related to normal threading? Please provide detail.
Upvotes: 3
Views: 723
Reputation: 457027
Normally, a single ASP.NET page request is handled by a single thread. After the thread sends the response, it returns to the ASP.NET thread pool.
When you use async
/await
(or asynchronous pages), the thread handling the request marks the request as incomplete and then returns to the ASP.NET thread pool. When the awaitable completes later, an ASP.NET thread is assigned to run the rest of the method.
More specifically, async
/await
by default use SynchronizationContext
. See my MSDN article for more details.
Upvotes: 1
Reputation: 52137
If you are interested in async
and await
keywords, you might find this Channel 9 interview with Anders Hejlsberg interesting.
Also, take a look at: this PDC video.
Upvotes: 2
Reputation: 58494
As already indicated before, async
keyword is part of .Net. For better implementation of asynchronous programming, Microsoft has released several CTPs for this and it will be out of the box on .Net 4.5 AFAIK.
Below article is helpful as well :
http://www.juliencorioland.net/Archives/en-aspnet-mvc-4-asynchronous-controllers
Upvotes: 1
Reputation: 161821
Async Tasks is a feature of .NET, not of ASP.NET MVC 4. They work the same in ASP.NET as they do elsewhere within .NET.
Upvotes: 0