asp.net 2.0 async vs ThreadPool.QueueUserWorkItem
am 05.01.2008 04:27:21 von robert112
Question... Can one not use ThreadPool.QueueUserWorkItem with an
anonymous method like so:
ThreadPool.QueueUserWorkItem(delegate
{
//perform IO bound operation.
});
Why did the asp.net team create the directive async=true way of
creating async pages???
Will the QueueUserWorkItem method not do the same thing???
Thanks.
Re: asp.net 2.0 async vs ThreadPool.QueueUserWorkItem
am 05.01.2008 14:02:33 von maciek kanski
robert112 wrote:
> Why did the asp.net team create the directive async=true way of
> creating async pages???
http://weblogs.asp.net/despos/archive/2005/10/19/427861.aspx
I think there're lot of things to discuss but in my opinion You should
use page-Async pattern in case of web applications performing long IO
operations; the idea is that IIS will break your page life-cycle
(somewhere between PreRender and Render) and in this time-gap the IIS
thread is free to serve another request while your page is performing
boring IO task in another thread; after completion your page again
returns to normal IIs thread to finish its cycle (Render, Unload, ....)
API details
> Will the QueueUserWorkItem method not do the same thing?
Well, I don't have experience with that class in case of web
applications; I propose use the page-Async solution that is designed for
web page while the ThreadPool is rather generic solution.
In special case of fire-and-forget work to be done I would consider
ThreadPool but I didn't look at all the pros and cons.
Regards