ServicePointManager.MaxServicePointIdleTime Właściwość

Definicja

Pobiera lub ustawia maksymalny czas ServicePoint bezczynności obiektu.

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

Wartość właściwości

Maksymalny czas bezczynności (w milisekundach) ServicePoint obiektu. Wartość domyślna to 100 000 milisekund (100 sekund).

Wyjątki

MaxServicePointIdleTime wartość jest mniejsza niż lub większa niż InfiniteInt32.MaxValue.

Przykłady

Poniższy przykład kodu ustawia tę właściwość.

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

Uwagi

Właściwość MaxServicePointIdleTime ustawia maksymalny czas bezczynności przypisywany ServicePointManager przez obiekt do MaxIdleTime właściwości podczas tworzenia ServicePoint obiektów. Zmiany tej wartości mają wpływ tylko ServicePoint na obiekty, które są inicjowane po zmianie wartości.

Gdy obiekt jest bezczynny przez czas określony w MaxIdleTimeelemecie ServicePoint , kwalifikuje się do odzyskiwania pamięci. ServicePoint Obiekt jest bezczynny, gdy lista połączeń skojarzonych z obiektem ServicePoint jest pusta.

Dotyczy

Zobacz też