ServicePoint.ConnectionLimit 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定這個 ServicePoint 對象上允許的連線數目上限。
public:
property int ConnectionLimit { int get(); void set(int value); };
public int ConnectionLimit { get; set; }
member this.ConnectionLimit : int with get, set
Public Property ConnectionLimit As Integer
屬性值
這個 ServicePoint 對象上允許的連線數目上限。
例外狀況
線上限制等於或小於 0。
範例
下列程式代碼範例會使用 ConnectionLimit 屬性來檢查 ServicePoint 物件可以對指定的統一資源識別碼 (URI) 進行的最大連線數目。
Console::WriteLine( "ConnectionName = {0}", sp->ConnectionName );
// Display the maximum number of connections allowed on this
// ServicePoint instance.
Console::WriteLine( "ConnectionLimit = {0}", sp->ConnectionLimit );
// Display the number of connections associated with this
// ServicePoint instance.
Console::WriteLine( "CurrentConnections = {0}", sp->CurrentConnections );
Console.WriteLine("ConnectionName = " + sp.ConnectionName);
// Display the maximum number of connections allowed on this
// ServicePoint instance.
Console.WriteLine("ConnectionLimit = " + sp.ConnectionLimit);
// Display the number of connections associated with this
// ServicePoint instance.
Console.WriteLine("CurrentConnections = " + sp.CurrentConnections);
Console.WriteLine(("ConnectionName = " + sp.ConnectionName))
' Display the maximum number of connections allowed on this
' ServicePoint instance.
Console.WriteLine(("ConnectionLimit = " + sp.ConnectionLimit.ToString()))
' Display the number of connections associated with this
' ServicePoint instance.
Console.WriteLine(("CurrentConnections = " + sp.CurrentConnections.ToString()))
備註
謹慎
WebRequest
、HttpWebRequest
、ServicePoint
和 WebClient
已經過時,您不應該將它們用於新的開發。 請改用 HttpClient。
ConnectionLimit 屬性會設定 ServicePoint 物件可以對因特網資源進行的最大連線數目。 建立 ServicePoint 物件時,ConnectionLimit 屬性的值會設定為 ServicePointManager.DefaultConnectionLimit 屬性的值;後續對 DefaultConnectionLimit 的變更不會影響現有的 ServicePoint 物件。