WebClient.OnDownloadDataCompleted(DownloadDataCompletedEventArgs) 方法
定义
引发 DownloadDataCompleted 事件。Raises the DownloadDataCompleted event.
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)
参数
包含事件数据的 DownloadDataCompletedEventArgs 对象。A DownloadDataCompletedEventArgs object that contains event data.
示例
下面的代码示例演示了此方法的一个实现,该实现可由派生自的类进行自定义 WebClient 。The following code example shows an implementation of this method that can be customized by a class derived from 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...
}
注解
从此类继承的类可以重写此方法,以便在事件发生时执行其他任务 DownloadDataCompleted 。Classes that inherit from this class can override this method to perform additional tasks when the DownloadDataCompleted event occurs.
引发事件时,将通过委托调用事件处理程序。Raising an event invokes the event handler through a delegate. 有关详细信息,请参阅 处理和引发事件For more information, see Handling and Raising Events
OnDownloadDataCompleted 方法还允许派生类对事件进行处理而不必附加委托。The OnDownloadDataCompleted method also allows derived classes to handle the event without attaching a delegate. 这是在派生类中处理事件的首选技术。This is the preferred technique for handling the event in a derived class.
继承者说明
当 OnDownloadDataCompleted(DownloadDataCompletedEventArgs) 在派生类中重写时,请确保调用基类的 OnDownloadDataCompleted(DownloadDataCompletedEventArgs) 方法,以便注册的委托接收事件。When overriding OnDownloadDataCompleted(DownloadDataCompletedEventArgs) in a derived class, be sure to call the base class' OnDownloadDataCompleted(DownloadDataCompletedEventArgs) method so that registered delegates receive the event.