BackgroundWorker.ProgressChanged 事件

定義

當呼叫 ReportProgress(Int32) 時發生。Occurs when ReportProgress(Int32) is called.

public:
 event System::ComponentModel::ProgressChangedEventHandler ^ ProgressChanged;
public event System.ComponentModel.ProgressChangedEventHandler ProgressChanged;
member this.ProgressChanged : System.ComponentModel.ProgressChangedEventHandler 
Public Custom Event ProgressChanged As ProgressChangedEventHandler 

範例

下列程式碼範例示範如何使用 ProgressChanged 事件來向使用者報告非同步作業的進度。The following code example demonstrates the use of the ProgressChanged event to report the progress of an asynchronous operation to the user. 這個程式碼範例是針對 BackgroundWorker 類別所提供的較大範例的一部分。This code example is part of a larger example provided 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

備註

當您呼叫 ReportProgress 方法時,就會引發這個事件。This event is raised when you call the ReportProgress method.

如需如何處理事件的詳細資訊,請參閱處理和引發事件For more information about how to handle events, see Handling and Raising Events.

適用於

另請參閱