Поделиться через


ServicePointManager.MaxServicePoints Свойство

Определение

Возвращает или задает максимальное количество ServicePoint объектов для обслуживания в любое время.

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

Значение свойства

Максимальное количество ServicePoint объектов для обслуживания. Значение по умолчанию равно 0, что означает, что количество объектов не ограничено ServicePoint .

Исключения

MaxServicePoints значение меньше 0 или больше , чем Int32.MaxValue.

Примеры

Следующий пример кода задает это свойство.

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

Комментарии

При снижении MaxServicePoints свойства ниже количества ServicePoint объектов в настоящее время удаляет ServicePointManagerServicePoint объекты с самым длинным временем простоя. Если число ServicePoint объектов с активными подключениями больше значения MaxServicePoints, ServicePointManager объект удаляет ServicePoint объекты по мере их простоя. Если этот предел задан и запрашиваются более отдельные ServicePoint экземпляры, FindServicePoint вызовет вызов. В результате HttpWebRequest запросы, ведущие к новым, отдельные конечные точки завершаются сбоем.

Замечание

Это свойство реализуется только в .NET Framework.

Применяется к

См. также раздел