ServicePointManager.MaxServicePoints Proprietà

Definizione

Ottiene o imposta il numero massimo di oggetti ServicePoint da gestire in qualsiasi 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

Valore della proprietà

Il numero massimo di oggetti ServicePoint da gestire. Il valore predefinito è 0 indicante che non esiste alcun limite al numero di oggetti ServicePoint.

Eccezioni

Esempio

Nell'esempio di codice seguente viene impostata questa proprietà.

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

Commenti

Quando si riduce la MaxServicePoints proprietà al di sotto del numero di ServicePoint oggetti attualmente presenti, ServicePointManager gli ServicePoint oggetti vengono eliminati con i tempi di inattività più lunghi. Se il numero di oggetti con connessioni attive è maggiore del valore di ServicePointMaxServicePoints, l'oggetto ServicePointManager elimina gli ServicePoint oggetti man mano che diventano inattive.

Si applica a

Vedi anche