WebClient.OnDownloadDataCompleted(DownloadDataCompletedEventArgs) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
引发 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)
参数
示例
下面的代码示例演示此方法的实现,该方法可由派生自 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...
}
注解
Caution
WebRequest、 HttpWebRequest、 ServicePoint和 WebClient 已过时,不应将其用于新开发。 改用 HttpClient。
继承自此类的类可以重写此方法,以在事件发生时 DownloadDataCompleted 执行其他任务。
引发事件会通过委托调用事件处理程序。 有关详细信息,请参阅 处理和引发事件。
该方法 OnDownloadDataCompleted 还允许派生类在不附加委托的情况下处理事件。 这是处理派生类中的事件的首选技术。
继承者说明
在派生类中重写 OnDownloadDataCompleted(DownloadDataCompletedEventArgs) 时,请务必调用基类 OnDownloadDataCompleted(DownloadDataCompletedEventArgs) 的方法,以便已注册的委托接收事件。