Export (0) Print
Expand All

ServicePoint.ConnectionLeaseTimeout Property

Gets or sets the number of milliseconds after which an active ServicePoint connection is closed.

Namespace: System.Net
Assembly: System (in system.dll)

'Declaration
Public Property ConnectionLeaseTimeout As Integer
'Usage
Dim instance As ServicePoint
Dim value As Integer

value = instance.ConnectionLeaseTimeout

instance.ConnectionLeaseTimeout = value
/** @property */
public int get_ConnectionLeaseTimeout ()

/** @property */
public void set_ConnectionLeaseTimeout (int value)

public function get ConnectionLeaseTimeout () : int

public function set ConnectionLeaseTimeout (value : int)

Not applicable.

Property Value

A Int32 that specifies the number of milliseconds that an active ServicePoint connection remains open. The default is -1, which allows an active ServicePoint connection to stay connected indefinitely. Set this property to 0 to force ServicePoint connections to close after servicing a request.

Exception typeCondition

ArgumentOutOfRangeException

The value specified for a set operation is a negative number less than -1.

You can use this property to ensure that a ServicePoint object's active connections do not remain open indefinitely. This property is intended for scenarios where connections should be dropped and reestablished periodically, such as load balancing scenarios.

By default, when KeepAlive is true for a request, the MaxIdleTime property sets the time-out for closing ServicePoint connections due to inactivity. If the ServicePoint has active connections, MaxIdleTime has no effect and the connections remain open indefinitely.

When the ConnectionLeaseTimeout property is set to a value other than -1, and after the specified time elapses, an active ServicePoint connection is closed after servicing a request by setting KeepAlive to false in that request.

Setting this value affects all connections managed by the ServicePoint object.

The following code example sets the value of this property.

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

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions

ADD
Show:
© 2014 Microsoft