ServicePointManager.MaxServicePoints Propriedade
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Obtém ou define o número máximo de ServicePoint objetos a manter em qualquer momento.
public:
static property int MaxServicePoints { int get(); void set(int value); };
public static int MaxServicePoints { get; set; }
static member MaxServicePoints : int with get, set
Public Shared Property MaxServicePoints As Integer
Valor de Propriedade
O número máximo de ServicePoint objetos a manter. O valor padrão é 0, o que significa que não há limite para o número de ServicePoint objetos.
Exceções
MaxServicePoints é inferior a 0 ou superior a Int32.MaxValue.
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
Quando se reduz a MaxServicePoints propriedade abaixo do número de ServicePoint objetos atualmente existentes, apaga-se ServicePointManager os ServicePoint objetos com os tempos de inatividade mais longos. Se o número de ServicePoint objetos com ligações ativas for maior do que o valor de MaxServicePoints, o ServicePointManager objeto elimina os ServicePoint objetos à medida que estes ficam inativos. Se este limite for definido e forem solicitadas mais instâncias distintas ServicePoint , FindServicePoint será lançado. Como resultado, HttpWebRequest os pedidos que conduzam a novos endpoints distintos falharão.
Note
Esta propriedade é implementada apenas no .NET Framework.