Partager via


ServicePointManager.MaxServicePoints Propriété

Définition

Obtient ou définit le nombre maximal d'objets ServicePoint à conserver à tout moment.

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

Valeur de propriété

Nombre maximal d'objets ServicePoint à conserver. La valeur par défaut est 0, ce qui signifie que le nombre d'objets ServicePoint est illimité.

Exceptions

MaxServicePoints est inférieur à 0 ou supérieur à Int32.MaxValue.

Exemples

L’exemple de code suivant définit cette propriété.

// 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

Remarques

Lorsque vous réduisez la MaxServicePoints propriété en dessous du nombre d’objets ServicePoint actuellement existants, le ServicePointManager supprime les objets avec les ServicePoint temps d’inactivité les plus longs. Si le nombre d’objets ServicePoint avec des connexions actives est supérieur à la valeur de MaxServicePoints, l’objet ServicePointManager supprime les objets lorsqu’ils ServicePoint deviennent inactifs.

S’applique à

Voir aussi