ServicePoint.MaxIdleTime 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置与 ServicePoint 对象关联的连接在关闭前可以持续空闲的时间。
public:
property int MaxIdleTime { int get(); void set(int value); };
public int MaxIdleTime { get; set; }
member this.MaxIdleTime : int with get, set
Public Property MaxIdleTime As Integer
属性值
与 ServicePoint 对象关联的连接在关闭和重用于另一个连接前可以持续空闲的时间长度(以毫秒为单位)。
例外
示例
下面的代码示例使用 MaxIdleTime 属性来设置和检索 ServicePoint 空闲时间。
// Display the date and time that the ServicePoint was last
// connected to a host.
Console::WriteLine( "IdleSince = {0}", sp->IdleSince );
// Display the maximum length of time that the ServicePoint instance
// is allowed to maintain an idle connection to an Internet
// resource before it is recycled for use in another connection.
Console::WriteLine( "MaxIdleTime = {0}", sp->MaxIdleTime );
// Display the date and time that the ServicePoint was last
// connected to a host.
Console.WriteLine("IdleSince = " + sp.IdleSince.ToString());
// Display the maximum length of time that the ServicePoint instance
// is allowed to maintain an idle connection to an Internet
// resource before it is recycled for use in another connection.
Console.WriteLine("MaxIdleTime = " + sp.MaxIdleTime);
' Display the date and time that the ServicePoint was last
' connected to a host.
Console.WriteLine(("IdleSince = " + sp.IdleSince.ToString()))
' Display the maximum length of time that the ServicePoint instance
' is allowed to maintain an idle connection to an Internet
' resource before it is recycled for use in another connection.
Console.WriteLine(("MaxIdleTime = " + sp.MaxIdleTime.ToString()))
注解
可以将 设置为 MaxIdleTimeTimeout.Infinite 以指示与 ServicePoint 对象关联的连接永远不会超时。
属性的MaxIdleTime默认值是创建 对象时ServicePoint属性的值ServicePointManager.MaxServicePointIdleTime。 对 属性的 MaxServicePointIdleTime 后续更改对现有 ServicePoint 对象没有影响。
MaxIdleTime当超过与 ServicePoint 关联的连接的 时,连接将保持打开状态,直到应用程序尝试使用该连接。 此时,框架将关闭连接,并创建与远程主机的新连接。
适用于
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈