This documentation is archived and is not being maintained.

Page.AsyncTimeout Property

Updated: October 2009

This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.

Gets or sets a value indicating the time-out interval used when processing asynchronous tasks.

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

public TimeSpan AsyncTimeout { get; set; }
<asp:Page AsyncTimeout="TimeSpan" />

Property Value

Type: System.TimeSpan
A TimeSpan that contains the allowed time interval for completion of the asynchronous task. The default time interval is 45 seconds.


The property was set to a negative value.

The asynchronous time-out of the page represents the amount of time that the page will wait to perform asynchronous tasks. In most circumstances, do not set this property in code. Set the page asynchronous time-out interval using the pages element of the Web configuration file or in the @ Page directive. Values set in the page configuration section are overwritten by the page directive.

Define your asynchronous task using the PageAsyncTask class and register a beginning, an ending, and a time-out handler. If the asynchronous task does not complete in the time interval specified, the time-out handler will be invoked.

The following code example demonstrates the use of the AsyncTimeout property with the ExecuteRegisteredAsyncTasks and RegisterAsyncTask methods. Note the use of beginning, ending, and time-out handlers. In the example, an artificial delay is introduced to demonstrate the situation of an asynchronous task exceeding the allotted time for the task as specified in the AsyncTimeout property. In a real-world scenario, an asynchronous task could be used to perform database calls or image generation, for example, and the time-out handler provides graceful degradation if the task is not performed in a specified amount of time. Note that the AsyncTimeout property is set in the page directive.

<%@ Page Language="C#" AsyncTimeout="2"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
<script runat="server">

  protected void Page_Load(object sender, EventArgs e)
    // Define the asynchronuous task.
    Samples.AspNet.CS.Controls.MyAsyncTask mytask =    
      new Samples.AspNet.CS.Controls.MyAsyncTask();
    PageAsyncTask asynctask = new PageAsyncTask(mytask.OnBegin, mytask.OnEnd, mytask.OnTimeout, null);

    // Register the asynchronous task.

    // Execute the register asynchronous task.

    TaskMessage.InnerHtml = mytask.GetAsyncTaskProgress();


<html xmlns="" >
<head runat="server">
    <title>Asynchronous Task Example</title>
    <form id="form1" runat="server">
      <span id="TaskMessage" runat="server">
using System;
using System.Web;
using System.Web.UI;
using System.Threading;

namespace Samples.AspNet.CS.Controls
	public class MyAsyncTask
		private String _taskprogress;
		private AsyncTaskDelegate _dlgt;

		// Create delegate. 
		protected delegate void AsyncTaskDelegate();

		public String GetAsyncTaskProgress()
			return _taskprogress;
		public void DoTheAsyncTask()
			// Introduce an artificial delay to simulate a delayed  
			// asynchronous task. Make this greater than the  
			// AsyncTimeout property.

		// Define the method that will get called to 
		// start the asynchronous task. 
		public IAsyncResult OnBegin(object sender, EventArgs e,
			AsyncCallback cb, object extraData)
			_taskprogress = "Beginning async task.";

			_dlgt = new AsyncTaskDelegate(DoTheAsyncTask);
			IAsyncResult result = _dlgt.BeginInvoke(cb, extraData);

                        return result;

		// Define the method that will get called when 
		// the asynchronous task is ended. 
		public void OnEnd(IAsyncResult ar)
			_taskprogress = "Asynchronous task completed.";

		// Define the method that will get called if the task 
		// is not completed within the asynchronous timeout interval. 
		public void OnTimeout(IAsyncResult ar)
			_taskprogress = "Ansynchronous task failed to complete " +
				"because it exceeded the AsyncTimeout parameter.";

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0




October 2009

Documented an exception.

Content bug fix.