Partager via


Generated Proxy Classes timeout Property

Gets or sets the time-out interval for the generated proxy class and its instances. This property exists at run time after the proxy class has been generated by the server.

Note

To get or set property values for client API properties, you must call property accessor methods that are named with the get_ and set_ prefixes. For example, to get or set a value for a property such as cancel, you call the get_cancel or set_cancel methods.

// Syntax for the generated proxy class.
var timeout = MyNameSpace.MyServiceProxy.get_timeout(); 
MyNameSpace.MyServiceProxy.set_timeout(value);

// Syntax for a proxy instance.
var timeout = myServiceProxy.get_timeout(); 
myServiceProxy.set_timeout(value);

Parameters

Parameter

Description

value

The time-out interval in milliseconds.

Return Value

The time-out value in milliseconds.

Remarks

The timeout property gets and sets the amount of time in milliseconds that the network executor should wait before timing out the Web request during calls to Web service methods. By setting a time-out interval, you make sure that a pending Web request returns control to your code faster than by waiting for the underlying network stack to time out during the request. If the timeout interval has not been previously set, the property returns the value of the Sys.Net.WebRequestManager.defaultTimeout property.

The network executor interprets a value of zero to mean that it is the responsibility of the underlying network stack to wait for the time out interval.

Example

The following example shows how to get and set the timeout property for the generated proxy class and for a proxy instance.

// This function sets and gets the timeout
// for the Web service generated proxy class.
function AssignTimeout() 
{
    // Define the timeout (100 msecs).
    var timeout = 100;

    // Set the timeout.
    Samples.AspNet.UsingProxyClass.set_timeout(timeout);

    // Get the timeout.
    timeout = 
        Samples.AspNet.UsingProxyClass.get_timeout();

    // Display the timeout.
    DisplayMessage("The proxy timeout is: " + timeout + " msecs.");
}
// This function sets and gets the timeout for an 
// instance of the Web service generated proxy class.
function AssignInstanceTimeout() 
{
    // Define the timeout (1000 msecs).
    var timeout = 1000;
    // Create an instance of the proxy class.
    var proxyInstance = 
        new Samples.AspNet.UsingProxyClass();

    // Set the timeout.
    proxyInstance.set_timeout(timeout);

    // Get the timeout.
    timeout = proxyInstance.get_timeout();

    // Display the timeout.
    DisplayMessage("The proxy instance timeout is: " + timeout + " msecs.");
}

See Also

Concepts

Sys.Net.WebServiceProxy Class