ServicePointManager.MaxServicePointIdleTime Propriedade

Definição

Obtém ou define o tempo máximo de inatividade de um ServicePoint objeto.

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

Valor de Propriedade

O tempo máximo de inatividade, em milissegundos, de um ServicePoint objeto. O valor padrão é 100.000 milissegundos (100 segundos).

Exceções

Exemplos

O seguinte exemplo de código define esta propriedade.

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

Observações

A MaxServicePointIdleTime propriedade define o tempo máximo de inatividade que o ServicePointManager objeto atribui à MaxIdleTime propriedade ao criar ServicePoint os objetos. As alterações a este valor afetam apenas ServicePoint objetos que são inicializados após a alteração do valor.

Depois de um ServicePoint objeto estar inativo durante o tempo especificado em MaxIdleTime, torna-se elegível para recolha de lixo. Um ServicePoint objeto está inativo quando a lista de ligações associadas ao ServicePoint objeto está vazia.

Note

Desde .NET 9, esta propriedade corresponde a SocketsHttpHandler.PooledConnectionIdleTimeout a menos que seja sobreposta por ServicePoint.MaxIdleTime. No entanto, os handlers não são reutilizados entre pedidos, por isso não tem qualquer impacto significativo.

Aplica-se a

Ver também