Export (0) Print
Expand All

ServicePointManager.MaxServicePoints Property

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

[Visual Basic]
Public Shared Property MaxServicePoints As Integer
[C#]
public static int MaxServicePoints {get; set;}
[C++]
public: __property static int get_MaxServicePoints();
public: __property static void set_MaxServicePoints(int);
[JScript]
public static function get MaxServicePoints() : int;
public static function set MaxServicePoints(int);

Property Value

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

Exceptions

Exception Type Condition
ArgumentOutOfRangeException MaxServicePoints is less than 0 or greater than Int32.MaxValue.

Remarks

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

Example

[Visual Basic, C#, C++] The following example sets this property.

[Visual Basic] 
' Set the maximum number of ServicePoint instances to maintain.
' Note that, 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. 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.
ServicePointManager.MaxServicePointIdleTime = 1000


[C#] 
// 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 = 1000;


[C++] 
// 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.
ServicePointManager::MaxServicePointIdleTime = 1000;

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Common Language Infrastructure (CLI) Standard

See Also

ServicePointManager Class | ServicePointManager Members | System.Net Namespace

Show:
© 2014 Microsoft