次の方法で共有


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.
ServicePointManager::MaxServicePointIdleTime = 10000;
// 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 数より小さくすると、 ServicePointManager は最も長いアイドル時間の ServicePoint オブジェクトを削除します。 アクティブな接続を持つオブジェクトの ServicePoint 数が の MaxServicePoints値を超える場合、 ServicePointManager オブジェクトはアイドル状態になるとオブジェクトを ServicePoint 削除します。

適用対象

こちらもご覧ください