ServicePoint.IdleSince 屬性
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得 ServicePoint 物件上次連接到主機的日期和時間。
public:
property DateTime IdleSince { DateTime get(); };
public DateTime IdleSince { get; }
member this.IdleSince : DateTime
Public ReadOnly Property IdleSince As DateTime
DateTime 物件,其中包含上次連接 ServicePoint 物件的日期和時間。
下列程式代碼範例會使用 IdleSince 屬性來設定和擷取 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()))
警告
WebRequest
、HttpWebRequest
、ServicePoint
和 WebClient
已經過時,您不應該將它們用於新的開發。 請改用 HttpClient。
IdleSince 屬性會記錄服務點與主機中斷連線的最後日期和時間。 當目前時間與 IdleSince 之間的差異超過 MaxIdleTime的值時,ServicePoint 物件可用來回收至另一個連接。
產品 | 版本 |
---|---|
.NET | Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0, 2.1 |