ServicePoint.ConnectionLimit 属性

定义

获取或设置此 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()))

注解

谨慎

WebRequestHttpWebRequestServicePointWebClient 已过时,不应将其用于新开发。 请改用 HttpClient

ConnectionLimit 属性设置 ServicePoint 对象可以连接到 Internet 资源的最大连接数。 创建 ServicePoint 对象时,ConnectionLimit 属性的值设置为 ServicePointManager.DefaultConnectionLimit 属性的值;对 DefaultConnectionLimit 的后续更改对现有 ServicePoint 对象没有影响。

适用于

另请参阅