WebClient.OnDownloadProgressChanged(DownloadProgressChangedEventArgs) 方法
定义
引发 DownloadProgressChanged 事件。Raises the DownloadProgressChanged event.
protected:
virtual void OnDownloadProgressChanged(System::Net::DownloadProgressChangedEventArgs ^ e);
protected virtual void OnDownloadProgressChanged (System.Net.DownloadProgressChangedEventArgs e);
abstract member OnDownloadProgressChanged : System.Net.DownloadProgressChangedEventArgs -> unit
override this.OnDownloadProgressChanged : System.Net.DownloadProgressChangedEventArgs -> unit
Protected Overridable Sub OnDownloadProgressChanged (e As DownloadProgressChangedEventArgs)
参数
包含事件数据的 DownloadProgressChangedEventArgs 对象。A DownloadProgressChangedEventArgs object containing 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 OnDownloadProgressChanged( DownloadProgressChangedEventArgs ^ e ) override
{
// Here you can perform any custom actions before the event is raised
// and event handlers are called...
WebClient::OnDownloadProgressChanged( e );
// Here you can perform any post event actions...
}
protected override void OnDownloadProgressChanged (DownloadProgressChangedEventArgs e)
{
// Here you can perform any custom actions before the event is raised
// and event handlers are called...
base.OnDownloadProgressChanged (e);
// Here you can perform any post event actions...
}
注解
从此类继承的类可以重写此方法,以便在事件发生时执行其他任务 DownloadProgressChanged 。Classes that inherit from this class can override this method to perform additional tasks when the DownloadProgressChanged event occurs.
引发事件时,将通过委托调用事件处理程序。Raising an event invokes the event handler through a delegate. 有关详细信息,请参阅 处理和引发事件。For more information, see Handling and Raising Events.
OnDownloadProgressChanged 方法还允许派生类对事件进行处理而不必附加委托。The OnDownloadProgressChanged 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.
继承者说明
当 OnDownloadProgressChanged(DownloadProgressChangedEventArgs) 在派生类中重写时,请确保调用基类的 OnDownloadProgressChanged(DownloadProgressChangedEventArgs) 方法,以便注册的委托接收事件。When overriding OnDownloadProgressChanged(DownloadProgressChangedEventArgs) in a derived class, be sure to call the base class' OnDownloadProgressChanged(DownloadProgressChangedEventArgs) method so that registered delegates receive the event.