Improve ASP.NET 2.0 Performance With PageAsyncTask - Multithreading For The Masses
Multithreading is tough. This is what John Robbins says about it in his excellent book Debugging Microsoft .NET 2.0 Applications: "Don't do it... Make sure there's no other way you can structure your program before you decide to incorporate multithreading into your application... you are easily adding a minimum of an extra month of development and testing to your schedule". I agree with it completely. But there are times multithreading is unavoidable. Especially when more and more Services popping up in the wild... | From Asynchronous Pages in ASP.NET 2.0 |
Customer Case Study
I am working with the customer to improve their ASP.NET 2.0 application performance. The application issues multiple requests to the backend middleware that is exposed as a web service. The application cannot get a hold on the actual proxies rather it is provided with the components that wrap the web services proxies. The application needs to issue concurrent requests. Serial request would result in serious latency which is unacceptable by end users.
Analysis
Since we cannot get hold on web services proxies we cannot utilize available asynchronous methods available with it: BeginMyMethod/EndMyMethod and MyMethodAsync/MyMethodCompleted. But we definitely can utilize another option available with ASP.NET 2.0 - registering asynchronous tasks using PageAsyncTask class.
The following information is based on the following materials:
PageAsyncTask Implementation Steps
This is the summary of the steps to implement and register PageAsyncTask:
- Create a class that contains lengthy operation
- Declare AsyncTaskDelegate
- Add OnBegin, OnEnd, OnTimeout methods to the class
- Mark the calling page as Async="true"
- Register the PageAsyncTasks in the ASPX page and execute it
You can grab the Visual Studio 2008 project with the implementation from my SkyDrive here:
Related Materials
- Improve ASP.NET Performance With Multithreading Using Thread Or ThreadPool Objects
- Do You Really Need A Distributed Architecture?
This template is made with PracticeThis.com plugin for Windows Live Writer