System.Web.UI.PageAsyncTask Class

Contains information about an asynchronous task registered to a page. This class cannot be inherited.

See Also: PageAsyncTask Members


public sealed class PageAsyncTask


ASP.NET version 2.0 allows you to register multiple tasks to a page and run them asynchronously prior to rendering the page. You might specify that a task be run asynchronously if it is a slow process and you do not want other processes to be tied up while it is executing. The asynchronous tasks can be executed in parallel or sequentially.

A System.Web.UI.PageAsyncTask object must be registered to the page through the Page.RegisterAsyncTask(PageAsyncTask) method. The page itself does not have to be processed asynchronously to execute asynchronous tasks. You can set the Async attribute to either true (as shown in the following code example) or false on the page directive and the asynchronous tasks will still be processed asynchronously:

<%@ Page Async="true" %>

When the Async attribute is set to false, the thread that executes the page will be blocked until all asynchronous tasks are complete.

Any asynchronous tasks registered before the Page.PreRenderComplete event will be executed automatically by the page if they have not already been executed. Those asynchronous tasks registered after the Page.PreRenderComplete event must be executed explicitly through the Page.ExecuteRegisteredAsyncTasks method. The Page.ExecuteRegisteredAsyncTasks method can also be used to start tasks before the Page.PreRenderComplete event. The Page.ExecuteRegisteredAsyncTasks method executes all the registered asynchronous tasks on the page that have not been executed.

By default, an asynchronous task will time out if it has not completed within 45 seconds. You can specify a different time-out value in either the Web.config file or the page directive. The <pages> section of the Web.config file contains an asyncTimeout attribute, as shown below.


<pages asyncTimeout="30">



The page directive contains an AsyncTimeout attribute.

<%@ Page AsyncTimeout="30" %>


Namespace: System.Web.UI
Assembly: System.Web (in System.Web.dll)
Assembly Versions: