When using PageAsynctask (Asynchronous ASP.NET page)

According to my understanding of reading about ASP.NET asynchronous pages, the method executed at the beginning of the asynchronous task is always executed between the pre-rendering and pre-rendering completion events. Because the controls of the page’ The event runs between the page loading and the pre-rendering event, so no matter what the start task handler (BeginAsync handler below) generates, it cannot be used in the event of the control? For example, if the handler gets data from the database, can the data not be used in the postback event of any control? Will you bind the data to the data control after pre-rendering?

PageAsyncTask pat = new PageAsyncTask(BeginAsync, EndAsync, null, null, true);
this.RegisterAsyncTask(pat);

< /div>

completely ignores Guffa’s answer and does not have enough reputation to vote for him, but this is completely misleading and terribly wrong . Tony_Henrich’s link is very good, this is another equally useful thing: http://msdn.microsoft.com/en-us/magazine/cc163725.aspx

All the DataSource controls are in Automatic data binding after Page_PreRender (if not manually before)-so yes, you can bind data in all PageAsyncTask event handlers, even Page_PreRenderComplete (only started after each PageAsyncTask is completed or timed out).

PageAsyncTask is best used when dealing with databases, web services, file I/O, and all other operations where the CPU is waiting for data processing-but not for CPU-intensive or long-running calculations (when the CPU is busy). /p>

Having said so much, pages will be processed faster only when two or more PageAsyncTasks are running in parallel – but even if there is only one PageAsyncTask, the request thread will be sent back to the pool (limited supply) , And the I/O thread will process the operation, thereby releasing IIS to receive more incoming requests until the task is completed (then it gets the request thread from the pool, not necessarily the same, and continues page processing).

According to my understanding of reading about ASP.NET asynchronous pages, the method executed at the beginning of the asynchronous task is always executed between the pre-rendering and pre-rendering completion events. Because the controls of the page’ The event runs between the page loading and the pre-rendering event, so no matter what the start task handler (BeginAsync handler below) generates, it cannot be used in the event of the control? For example, if the handler gets data from the database, can the data not be used in the postback event of any control? Will you bind the data to the data control after pre-rendering?

PageAsyncTask pat = new PageAsyncTask(BeginAsync, EndAsync, null, null, true);
this.RegisterAsyncTask(pat);

< /p>

Completely ignoring Guffa’s answer, there is not enough reputation to vote for him, but this is totally misleading and terribly wrong. Tony_Henrich’s link is very good, this is another same Useful things: http://msdn.microsoft.com/en-us/magazine/cc163725.aspx

All DataSource controls are automatically data bound after Page_PreRender (if you have not manually ) – So yes, you can bind the data in all PageAsyncTask event handlers, even Page_PreRenderComplete (only started after each PageAsyncTask is completed or timed out).

PageAsyncTask is most suitable for processing databases, Web Services, file I/O, and all other operations of the CPU waiting for data processing-but not suitable for CPU-intensive or long-running calculations (when the CPU is busy).

Having said so much, only When two or more PageAsyncTask run in parallel, the page will be processed faster-but even if there is only one PageAsyncTask, the request thread will be sent back to the pool (limited supply), and the I/O thread will process the operation, thereby freeing IIS to receive more incoming requests until the task is completed (then it gets the request thread from the pool, not necessarily the same, and continues page processing).

Leave a Comment

Your email address will not be published.