Export (0) Print
Expand All

ServicePointManager.MaxServicePoints Property

Gets or sets the maximum number of ServicePoint objects to maintain at any time.

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

public static int MaxServicePoints { get; set; }
/** @property */
public static int get_MaxServicePoints ()

/** @property */
public static void set_MaxServicePoints (int value)

public static function get MaxServicePoints () : int

public static function set MaxServicePoints (value : int)

Not applicable.

Property Value

The maximum number of ServicePoint objects to maintain. The default value is 0, which means there is no limit to the number of ServicePoint objects.

Exception typeCondition

ArgumentOutOfRangeException

MaxServicePoints is less than 0 or greater than Int32.MaxValue.

When you reduce the MaxServicePoints property below the number of ServicePoint objects currently in existence, the ServicePointManager deletes the ServicePoint objects with the longest idle times. If the number of ServicePoint objects with active connections is greater than the value of MaxServicePoints, the ServicePointManager object deletes the ServicePoint objects as they become idle.

The following code example sets this property.

// Set the maximum number of ServicePoint instances to 
// maintain. If a ServicePoint instance for that host already 
// exists when your application requests a connection to
// an Internet resource, the ServicePointManager object
// returns this existing ServicePoint instance. If none exists 
// for that host, it creates a new ServicePoint instance.
ServicePointManager.MaxServicePoints = 4;

// Set the maximum idle time of a ServicePoint instance to 10 seconds.
// After the idle time expires, the ServicePoint object is eligible for
// garbage collection and cannot be used by the ServicePointManager object.
ServicePointManager.MaxServicePointIdleTime = 10000;


// Set the maximum number of ServicePoint instances to 
// maintain. If a ServicePoint instance for that host already 
// exists when your application requests a connection to
// an Internet resource, the ServicePointManager object
// returns this existing ServicePoint instance. If none exists 
// for that host, it creates a new ServicePoint instance.
ServicePointManager.set_MaxServicePoints(4);

// Set the maximum idle time of a ServicePoint instance to 10 seconds.
// After the idle time expires, the ServicePoint object is eligible 
// for garbage collection and cannot be used by the ServicePointManager
// object.
ServicePointManager.set_MaxServicePointIdleTime(10000);

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, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft