System.Web 2.0.0.0 System.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 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 event will be executed automatically by the page if they have not already been executed. Those asynchronous tasks registered after the event must be executed explicitly through the method. The method can also be used to start tasks before the event. The 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.

<system.web>

<pages asyncTimeout="30">

</pages>

</system.web>

The page directive contains an AsyncTimeout attribute.

<%@ Page AsyncTimeout="30" %>

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

- Constructor
  2.0.0.0

  This implementation of the constructor sets the property to false so the asynchronous task is not processed in parallel with other tasks on the page.

  Initializes a new instance of the class using the default value for executing in parallel.

  The handler to call when beginning an asynchronous task.
  The handler to call when the task is completed successfully within the time-out period.
  The handler to call when the task is not completed successfully within the time-out period.
  The object that represents the state of the task.
- Constructor
  2.0.0.0

  This implementation of the constructor allows you to set whether the asynchronous task will be processed in parallel with other tasks on the page.

  Initializes a new instance of the class using the specified value for executing in parallel.

  The handler to call when beginning an asynchronous task.
  The handler to call when the task is completed successfully within the time-out period.
  The handler to call when the task is not completed successfully within the time-out period.
  The object that represents the state of the task.
  The value that indicates whether the task can be processed in parallel with other tasks.
- Property
  2.0.0.0
  System.Web.BeginEventHandler To be added.

  The delegate is set in the constructor.

  Gets the method to call when beginning an asynchronous task.

- Property
  2.0.0.0
  System.Web.EndEventHandler To be added.

  The delegate is set in the constructor.

  Gets the method to call when the task completes successfully within the time-out period.

- Property
  2.0.0.0
  System.Boolean To be added.

  The property is set in the constructor. When multiple tasks are registered in a page and the property is set to true, then those tasks are processed concurrently. However, if the property is set to false, then those tasks are processed sequentially. For example, if a page contained two asynchronous tasks that each took 5 seconds to complete and is set to true, both tasks will complete in 5 seconds. If is set to false for these same two tasks, then the first task will complete in 5 seconds and the second task will complete 5 seconds after the completion of the first task.

  Gets a value that indicates whether the task can be processed in parallel with other tasks.

- Property
  2.0.0.0
  System.Object To be added.

  The property is set in the constructor and cannot be modified during execution of the asynchronous task. You can differentiate asynchronous tasks in a page by assigning unique string values to their respective properties.

  Gets an object that represents the state of the task.

- Property
  2.0.0.0
  System.Web.EndEventHandler To be added.

  The delegate is set in the constructor.

  Gets the method to call when the task does not complete successfully within the time-out period.