Jon Flanders pointed out that the async flag I mentioned in my last blog entry of the Page class in ASP.NET 2.0 does in fact alter the generated code, and is not just a 'placebo' as I indicated. I thought it was worth a follow-up post describing exactly what it does in the current release bits.
If you mark a page as async, the generated Page-derived class is altered in the following ways:
- It implements IHttpAsyncHandler
- It sets the AsyncMode property to true in the constructor
- It implements IHttpAsyncHandler.BeginRequest/EndRequest by forwarding the calls to AsyncPageBeginProcessRequest/AsyncPageEndProcessRequest
public virtual System.IAsyncResult BeginProcessRequest(HttpContext context,
AsyncCallback cb, object data) {
return this.AsyncPageBeginProcessRequest(context, cb, data);
}
public virtual void EndProcessRequest(System.IAsyncResult ar) {
this.AsyncPageEndProcessRequest(ar);
}
What's interesting, is that the infrastructure is all in place to process this page on a different thread from the request thread, but it never actually creates a second thread to do the work on. Instead the async handler methods are invoked synchronously from the request thread. We'll have to wait and see how this turns out in the final release.
Posted
Aug 16 2004, 02:10 PM
by
fritz-onion