ServicePointManager.MaxServicePoints Propiedad

Definición

Obtiene o establece el número máximo de objetos ServicePoint que deben mantenerse en cualquier momento.

public:
 static property int MaxServicePoints { int get(); void set(int value); };
public static int MaxServicePoints { get; set; }
static member MaxServicePoints : int with get, set
Public Shared Property MaxServicePoints As Integer

Valor de propiedad

El número máximo de objetos ServicePoint que se deben mantener. El valor predeterminado es 0, es decir, no hay límite para el número de objetos ServicePoint.

Excepciones

Ejemplos

En el ejemplo de código siguiente se establece esta propiedad.

// 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 = 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.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.
' 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 = 10000

Comentarios

Al reducir la MaxServicePoints propiedad por debajo del número de objetos que existen actualmente, ServicePointManager elimina los ServicePoint objetos con los tiempos de ServicePoint inactividad más largos. Si el número de ServicePoint objetos con conexiones activas es mayor que el valor de MaxServicePoints, el ServicePointManager objeto elimina los ServicePoint objetos a medida que se vuelven inactivos.

Se aplica a

Consulte también