語言

ServicePoint.IdleSince 屬性

定義

取得物件最後一次連接到主機的 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 = " + 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、ServicePointWebClient、和 都已過時,你不應該用它們來做新開發。 請改用 HttpClient。

該財產會 IdleSince 記錄服務點與主機斷線的最後日期與時間。 當當前時間與 IdleSince 的差值超過時 MaxIdleTime,該 ServicePoint 物件可回收至另一個連線。

適用於