ServicePoint.MaxIdleTime Propriedade
Definição
Importante
Algumas informações se referem a produtos de pré-lançamento que podem ser substancialmente modificados antes do lançamento. A Microsoft não oferece garantias, expressas ou implícitas, das informações aqui fornecidas.
Obtém ou define por quanto tempo uma conexão associada ao objeto ServicePoint pode permanecer ociosa antes que a conexão seja fechada.
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 da propriedade
O período, em milissegundos, que uma conexão associada ao objeto ServicePoint pode permanecer ociosa antes de ser fechada e reutilizada para outra conexão.
Exceções
MaxIdleTime é definido como menor Infinite ou maior que Int32.MaxValue.
Exemplos
O exemplo de código a seguir usa a MaxIdleTime propriedade para definir e recuperar o tempo ocioso ServicePoint .
// Display the date and time that the ServicePoint was last
// connected to a host.
Console::WriteLine( "IdleSince = {0}", sp->IdleSince );
// 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 = {0}", 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);
' 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()))
Comentários
Você pode definir MaxIdleTime como Timeout.Infinite para indicar que uma conexão associada ao objeto nunca deve atingir o ServicePoint tempo limite.
O valor padrão da MaxIdleTime propriedade é o valor da ServicePointManager.MaxServicePointIdleTime propriedade quando o ServicePoint objeto é criado. As alterações subsequentes na MaxServicePointIdleTime propriedade não têm efeito sobre os objetos existentes ServicePoint .
Quando o MaxIdleTime para uma conexão associada a um ServicePoint é excedido, a conexão permanece aberta até que o aplicativo tente usar a conexão. Nesse momento, a Estrutura fecha a conexão e cria uma nova conexão com o host remoto.
Aplica-se a
Comentários
https://aka.ms/ContentUserFeedback.
Em breve: Ao longo de 2024, eliminaremos os problemas do GitHub como o mecanismo de comentários para conteúdo e o substituiremos por um novo sistema de comentários. Para obter mais informações, consulteEnviar e exibir comentários de