ProgressChangedEventHandler 代理人

定義

代表將處理 ProgressChanged 類別的 BackgroundWorker 事件之方法。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. 若要使事件與您的事件處理常式產生關聯,請將委派的執行個體 (Instance) 加入至事件。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.

適用於