Contains information about an asynchronous task registered to a page. This class cannot be inherited.
Assembly: System.Web (in System.Web.dll)
Thetype exposes the following members.
|PageAsyncTask(BeginEventHandler, EndEventHandler, EndEventHandler, Object)||Initializes a new instance of the class using the default value for executing in parallel.|
|PageAsyncTask(BeginEventHandler, EndEventHandler, EndEventHandler, Object, Boolean)||Initializes a new instance of the class using the specified value for executing in parallel.|
|BeginHandler||Gets the method to call when beginning an asynchronous task.|
|EndHandler||Gets the method to call when the task completes successfully within the time-out period.|
|ExecuteInParallel||Gets a value that indicates whether the task can be processed in parallel with other tasks.|
|State||Gets an object that represents the state of the task.|
|TimeoutHandler||Gets the method to call when the task does not complete successfully within the time-out period.|
|Equals(Object)||Determines whether the specified Object is equal to the current Object. (Inherited from Object.)|
|Finalize||Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)|
|GetHashCode||Serves as a hash function for a particular type. (Inherited from Object.)|
|GetType||Gets the Type of the current instance. (Inherited from Object.)|
|MemberwiseClone||Creates a shallow copy of the current Object. (Inherited from Object.)|
|ToString||Returns a string that represents the current object. (Inherited from Object.)|
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 object must be registered to the page through the RegisterAsyncTask 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 PreRenderComplete event will be executed automatically by the page if they have not already been executed. Those asynchronous tasks registered after the PreRenderComplete event must be executed explicitly through the ExecuteRegisteredAsyncTasks method. The ExecuteRegisteredAsyncTasks method can also be used to start tasks before the PreRenderComplete event. The 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.
The page directive contains an AsyncTimeout attribute.
<%@ Page AsyncTimeout="30" %>
The following code example registers three asynchronous tasks to a page and executes them in parallel. Each task calls a method that merely causes the thread to sleep for 5 seconds.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.