Hi
I answered your question and it got deleted :(
You can't get the response object after the page loaded. So your way won't work.
The concept of Async programing in Asp.Net is different from Win Form. In ASP.net it is used to free http request processing threads, so that concurrent requests can be processed without waiting for a long running background process like a web service contacts.
For example person A request a page which takes long time due to a background processing (contacting the webservice). Like this a few requests consume all the http request processing threads in the pool. So When person B request a page which even don't have any background processing work will have to wait for long time as there is no thread available in the pool to handle it.
For this reason in asp.net has an option Async handling to optimize the performance of the webserver.
Where the http request will be handled through a custom
IAsyncHttpHandler
implemented class. It has the async methods
BeginProcessRequest
and
EndProcessRequest
.
Using that you can intercept the data being send to the response stream and it will free the main thread available for handle next http request.
Otherwise handle the async request using Ajax
Follow the guidelines here...
http://msdn.microsoft.com/en-us/library/ms227433.aspx[
^]
http://www.devx.com/asp/Article/29617[
^]
Processing Long Running Tasks With Asynchronous Handlers and XMLHTTP[
^]
Hope this helps