![]() |
|
06.30.08 Using The IHttpAsyncHandler In ASP.NET By Mads Kristensen I've known about the IHttpAsyncHandler interface for a long time, but never really had the time to play around with it. After a brief web search I realized that not many people have. There are no easy to understand articles or blog posts on the subject, so I thought I'd investigate and share. Basically, the IHttpAsyncHandler interface allows you to serve content asynchronously from a HTTP handler. This is great when you need to free up the worker thread to do processing like IO work etc. ASP.NET actually uses fewer threads when it runs asynchronously, which is great for performance and scalability. That's because each thread is returned much faster to the thread pool. The IHttpAsyncHandler is very similar to IHttpHandler interface, but with two extra methods to override - BeginProcessRequest and EndProcessRequest. From there you invoke a delegate to handle the processing asynchronously. It sounds complicated, but it really isn't. Here is an example that removes the complicated stuff and gives you one single method to modify. The code The example is a handler that is used to serve files for download. Serving a file requires IO access and therefore it is a great candidate for asynchronous serving. As you can see, the ServeContent method is all there is needed for the specific task of serving files. Just modify it to whatever purpose you find fit.
Continue reading this article.
|
||||||||||
|
|
|
| -- DevWebPro India
is an iEntry, Inc. publication -- iEntry, Inc. 2549 Richmond Rd. Lexington KY, 40509 2008 iEntry, Inc. All Rights Reserved Privacy Policy Legal archives | advertising info | news headlines | free newsletters | comments/feedback | submit article |