ProgressChangedEventHandler 委托

定义

表示将处理 BackgroundWorker 类的 ProgressChanged 事件的方法。Represents the method that will handle the ProgressChanged event of the BackgroundWorker class. 此类不能被继承。This class cannot be inherited.

public delegate void ProgressChangedEventHandler(System::Object ^ sender, ProgressChangedEventArgs ^ e);
public delegate void ProgressChangedEventHandler(object sender, ProgressChangedEventArgs e);
type ProgressChangedEventHandler = delegate of obj * ProgressChangedEventArgs -> unit
Public Delegate Sub ProgressChangedEventHandler(sender As Object, e As ProgressChangedEventArgs)

参数

sender
Object

事件源。The source of the event.

e
ProgressChangedEventArgs

包含事件数据的 ProgressChangedEventArgsA ProgressChangedEventArgs that contains the event data.

继承
ProgressChangedEventHandler

示例

下面的代码示例演示如何使用 ProgressChangedEventHandler 类。The following code example shows how to use the ProgressChangedEventHandler class. 此示例是BackgroundWorker类的一个更大示例的一部分。This example is part of a larger example for the BackgroundWorker class.

// This event handler updates the progress bar.
void backgroundWorker1_ProgressChanged( Object^ /*sender*/, ProgressChangedEventArgs^ e )
{
   this->progressBar1->Value = e->ProgressPercentage;
}
// This event handler updates the progress bar.
private void backgroundWorker1_ProgressChanged(object sender,
    ProgressChangedEventArgs e)
{
    this.progressBar1.Value = e.ProgressPercentage;
}
' This event handler updates the progress bar.
Private Sub backgroundWorker1_ProgressChanged( _
ByVal sender As Object, ByVal e As ProgressChangedEventArgs) _
Handles backgroundWorker1.ProgressChanged

    Me.progressBar1.Value = e.ProgressPercentage

End Sub

注解

创建ProgressChangedEventHandler委托时, 需要标识用于处理事件的方法。When you create a ProgressChangedEventHandler delegate, you identify a method to handle the event. 若要将事件与事件处理程序关联,请将该委托的一个实例添加到事件中。To associate the event with your event handler, add an instance of the delegate to the event. 除非移除了该委托,否则每当发生该事件时就会调用事件处理程序。The event handler is called whenever the event occurs, unless you remove the delegate. 有关事件处理程序委托的详细信息, 请参阅处理和引发事件For more information about event handler delegates, see Handling and Raising Events.

扩展方法

GetMethodInfo(Delegate)

获取指示指定委托表示的方法的对象。Gets an object that represents the method represented by the specified delegate.

适用于