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