Jun 262006
ASP.NET 2.0 includes simple support for asynchronous pages. The same framework can be used at any control level– including the page, control and webpart classes. The code will also execute EITHER syncronously or asyncronously, depending on the async value of the page.
We’ll be talking about this at great length at next month’s Denver Visual Studio .NET User Group, where I’ll be presenting on the topic of "Getting More out of ASP.NET 2.0". Async pages are one of the three keys to a responsive ASP.NET 2.0 application, the other 2 being Atlas WebService calls (no more postbacks) and caching. Basically, the async code returns the IIS worker thread to the thread pool while it waits for the async task to complete. This frees up your IIS Web Server to handle more requests as your database or remote webservice takes care of the long running tasks.
To make a WebPart asynchrounous, instead of using the old WSS async framework just use the new Page class’s RegisterAsyncTask method:

new PageAsyncTask(
          new BeginEventHandler(BeginGetFoo),
new EndEventHandler(EndGetFoo),
          new EndEventHandler(GetFooTimeout),
     null, true));

This will register the BeginGetFoo method as the start method and the  EndGetFoo method as the callback. This is great for webservice calls or ADO.NET calls since both of these support async calls out of the box. It might take you a bit to add asynch support to your middle tier code, but this should be a target for most portal developer’s frameworks in 2006. It is also worth noting that async pages are NOT enabled out of the box with SharePoint 2007, this is a setting you’ll need to edit in your SiteTemplates aspx pages or change globally in web.config.

 Leave a Reply



You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>