Sdílet prostřednictvím


ServicePointManager.MaxServicePointIdleTime Vlastnost

Definice

Získá nebo nastaví maximální dobu nečinnosti objektu ServicePoint .

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

Hodnota vlastnosti

Maximální doba nečinnosti objektu ServicePoint v milisekundách. Výchozí hodnota je 100 000 milisekund (100 sekund).

Výjimky

Příklady

Následující příklad kódu nastaví tuto vlastnost.

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

Poznámky

Vlastnost MaxServicePointIdleTime nastaví maximální dobu nečinnosti, kterou ServicePointManager objekt přiřadí vlastnosti MaxIdleTime při vytváření ServicePoint objektů. Změny této hodnoty mají vliv pouze ServicePoint na objekty inicializované po změně hodnoty.

ServicePoint Jakmile je objekt po dobu určenou v MaxIdleTimenečinnosti , je způsobilý pro uvolňování paměti. Objekt ServicePoint je nečinný, pokud je seznam připojení přidružených k objektu ServicePoint prázdný.

Poznámka:

Vzhledem k tomu, .NET 9, tato vlastnost mapuje na SocketsHttpHandler.PooledConnectionIdleTimeout , pokud není přepsána ServicePoint.MaxIdleTime. Obslužné rutiny se ale mezi požadavky opakovaně nepoužívají, takže nemají žádný smysluplný dopad.

Platí pro

Viz také