WebClient.OnOpenReadCompleted(OpenReadCompletedEventArgs) 方法

定义

引发 OpenReadCompleted 事件。

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

参数

e
OpenReadCompletedEventArgs

包含事件数据的 OpenReadCompletedEventArgs 对象。

示例

下面的代码示例演示此方法的实现,该方法可由派生自 WebClient的类进行自定义。

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

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

    base.OnOpenReadCompleted (e);

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

注解

从此类继承的类可以重写此方法,以在事件发生时 OpenReadCompleted 执行其他任务。

引发事件时,将通过委托调用事件处理程序。 有关详细信息,请参阅 处理和引发事件

OnOpenReadCompleted 方法还允许派生类对事件进行处理而不必附加委托。 这是在派生类中处理事件的首选技术。

继承者说明

在派生类中重写 OnOpenReadCompleted(OpenReadCompletedEventArgs) 时,请务必调用基类的 OnOpenReadCompleted(OpenReadCompletedEventArgs) 方法,以便注册的委托接收 事件。

适用于