ServicePoint.MaxIdleTime Propriedade

Definição

Obtém ou define o tempo em que uma ligação associada ao ServicePoint objeto pode permanecer inativa antes de a ligação ser encerrada.

public:
 property int MaxIdleTime { int get(); void set(int value); };
public int MaxIdleTime { get; set; }
member this.MaxIdleTime : int with get, set
Public Property MaxIdleTime As Integer

Valor de Propriedade

O tempo, em milissegundos, em que uma ligação associada ao ServicePoint objeto pode permanecer ociosa antes de ser fechada e reutilizada para outra ligação.

Exceções

MaxIdleTime é definido como menor ou Infinite superior a Int32.MaxValue.

Exemplos

O seguinte exemplo de código usa a MaxIdleTime propriedade para definir e recuperar o ServicePoint tempo de inatividade.

// Display the date and time that the ServicePoint was last
// connected to a host.
Console.WriteLine("IdleSince = " + sp.IdleSince.ToString());

// Display the maximum length of time that the ServicePoint instance
// is allowed to maintain an idle connection to an Internet
// resource before it is recycled for use in another connection.
Console.WriteLine("MaxIdleTime = " + sp.MaxIdleTime);
' Display the date and time that the ServicePoint was last 
' connected to a host.
Console.WriteLine(("IdleSince = " + sp.IdleSince.ToString()))


' Display the maximum length of time that the ServicePoint instance 
' is allowed to maintain an idle connection to an Internet  
' resource before it is recycled for use in another connection.
Console.WriteLine(("MaxIdleTime = " + sp.MaxIdleTime.ToString()))

Observações

Atenção

WebRequest, HttpWebRequest, ServicePoint, e WebClient são obsoletos, e não deves usá-los para novos desenvolvimentos. Utilize HttpClient em substituição.

Pode definir MaxIdleTime para Timeout.Infinite indicar que uma ligação associada ao ServicePoint objeto nunca deve expirar.

O valor padrão da MaxIdleTime propriedade é o valor da ServicePointManager.MaxServicePointIdleTime propriedade quando o ServicePoint objeto é criado. Alterações subsequentes à MaxServicePointIdleTime propriedade não têm efeito sobre objetos existentes ServicePoint .

Quando o MaxIdleTime para uma ligação associada a ServicePoint é ultrapassado, a ligação permanece aberta até que a aplicação tente usar a ligação. Nesse momento, o Framework fecha a ligação e cria uma nova ligação ao host remoto.

Note

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

Aplica-se a