語言

WebClient.OnDownloadDataCompleted(DownloadDataCompletedEventArgs) 方法

定義

引發 DownloadDataCompleted 事件。

protected:
 virtual void OnDownloadDataCompleted(System::Net::DownloadDataCompletedEventArgs ^ e);
protected virtual void OnDownloadDataCompleted(System.Net.DownloadDataCompletedEventArgs e);
abstract member OnDownloadDataCompleted : System.Net.DownloadDataCompletedEventArgs -> unit
override this.OnDownloadDataCompleted : System.Net.DownloadDataCompletedEventArgs -> unit
Protected Overridable Sub OnDownloadDataCompleted (e As DownloadDataCompletedEventArgs)

參數

e
DownloadDataCompletedEventArgs

一個 DownloadDataCompletedEventArgs 包含事件資料的物件。

範例

以下程式碼範例展示了此方法的實作,可由由 WebClient衍生的類別自訂。

virtual void OnDownloadDataCompleted( DownloadDataCompletedEventArgs ^ e ) override
{
   // Here you can perform any custom actions before the event is raised
   // and event handlers are called...
   WebClient::OnDownloadDataCompleted( e );

   // Here you can perform any post event actions...
}
protected override void OnDownloadDataCompleted (DownloadDataCompletedEventArgs e)
{
    // Here you can perform any custom actions before the event is raised
    // and event handlers are called...

    base.OnDownloadDataCompleted(e);

    // Here you can perform any post event actions...
}

備註

注意事項

WebRequest、、HttpWebRequest、ServicePointWebClient、和 都已過時,你不應該用它們來做新開發。 請改用 HttpClient。

繼承自此類別的類別可以覆寫此方法,在事件 DownloadDataCompleted 發生時執行額外任務。

發起事件會透過代理呼叫事件處理者。 欲了解更多資訊,請參閱 處理與提升事件。

此 OnDownloadDataCompleted 方法也允許衍生類別在不附加代理的情況下處理事件。 這是在衍生類別中處理事件的首選技術。

給繼承者的注意事項

在導出類別中覆寫 OnDownloadDataCompleted(DownloadDataCompletedEventArgs) 時,務必呼叫基底類別的方法 OnDownloadDataCompleted(DownloadDataCompletedEventArgs) ,讓註冊代理接收事件。

適用於