RunWorkerCompletedEventArgs RunWorkerCompletedEventArgs RunWorkerCompletedEventArgs RunWorkerCompletedEventArgs Class

정의

MethodNameCompleted 이벤트에 대한 데이터를 제공합니다.Provides data for the MethodNameCompleted event.

public ref class RunWorkerCompletedEventArgs : System::ComponentModel::AsyncCompletedEventArgs
public class RunWorkerCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs
type RunWorkerCompletedEventArgs = class
    inherit AsyncCompletedEventArgs
Public Class RunWorkerCompletedEventArgs
Inherits AsyncCompletedEventArgs
상속
RunWorkerCompletedEventArgsRunWorkerCompletedEventArgsRunWorkerCompletedEventArgsRunWorkerCompletedEventArgs

예제

다음 코드 예제에서는 RunWorkerCompletedEventArgs합니다.The following code example illustrates the use of RunWorkerCompletedEventArgs. 이 예제는에 대 한 더 큰 샘플의 일부를 BackgroundWorker 클래스입니다.This example is part of a larger sample for the BackgroundWorker class.

// This event handler deals with the results of the
// background operation.
void backgroundWorker1_RunWorkerCompleted( Object^ /*sender*/, RunWorkerCompletedEventArgs^ e )
{
   // First, handle the case where an exception was thrown.
   if ( e->Error != nullptr )
   {
      MessageBox::Show( e->Error->Message );
   }
   else
   if ( e->Cancelled )
   {
      // Next, handle the case where the user cancelled 
      // the operation.
      // Note that due to a race condition in 
      // the DoWork event handler, the Cancelled
      // flag may not have been set, even though
      // CancelAsync was called.
      resultLabel->Text = "Cancelled";
   }
   else
   {
      // Finally, handle the case where the operation 
      // succeeded.
      resultLabel->Text = e->Result->ToString();
   }

   // Enable the UpDown control.
   this->numericUpDown1->Enabled = true;

   // Enable the Start button.
   startAsyncButton->Enabled = true;

   // Disable the Cancel button.
   cancelAsyncButton->Enabled = false;
}
// This event handler deals with the results of the
// background operation.
private void backgroundWorker1_RunWorkerCompleted(
    object sender, RunWorkerCompletedEventArgs e)
{
    // First, handle the case where an exception was thrown.
    if (e.Error != null)
    {
        MessageBox.Show(e.Error.Message);
    }
    else if (e.Cancelled)
    {
        // Next, handle the case where the user canceled 
        // the operation.
        // Note that due to a race condition in 
        // the DoWork event handler, the Cancelled
        // flag may not have been set, even though
        // CancelAsync was called.
        resultLabel.Text = "Canceled";
    }
    else
    {
        // Finally, handle the case where the operation 
        // succeeded.
        resultLabel.Text = e.Result.ToString();
    }

    // Enable the UpDown control.
    this.numericUpDown1.Enabled = true;

    // Enable the Start button.
    startAsyncButton.Enabled = true;

    // Disable the Cancel button.
    cancelAsyncButton.Enabled = false;
}
' This event handler deals with the results of the
' background operation.
Private Sub backgroundWorker1_RunWorkerCompleted( _
ByVal sender As Object, ByVal e As RunWorkerCompletedEventArgs) _
Handles backgroundWorker1.RunWorkerCompleted

    ' First, handle the case where an exception was thrown.
    If (e.Error IsNot Nothing) Then
        MessageBox.Show(e.Error.Message)
    ElseIf e.Cancelled Then
        ' Next, handle the case where the user canceled the 
        ' operation.
        ' Note that due to a race condition in 
        ' the DoWork event handler, the Cancelled
        ' flag may not have been set, even though
        ' CancelAsync was called.
        resultLabel.Text = "Canceled"
    Else
        ' Finally, handle the case where the operation succeeded.
        resultLabel.Text = e.Result.ToString()
    End If

    ' Enable the UpDown control.
    Me.numericUpDown1.Enabled = True

    ' Enable the Start button.
    startAsyncButton.Enabled = True

    ' Disable the Cancel button.
    cancelAsyncButton.Enabled = False
End Sub

설명

비동기 작업에 이벤트 기반 비동기 패턴 을 사용 하는 경우 Windows Forms 폼 이나 컨트롤은 메서드를 BackgroundWorker.RunWorkerAsync 호출 하 여 비동기 작업을 시작 합니다.When using the event-based asynchronous pattern for asynchronous operations, a Windows Forms form or control initiates an asynchronous operation by calling the BackgroundWorker.RunWorkerAsync method. 메서드를 발생 시킵니다 합니다 BackgroundWorker.DoWork 이벤트 비동기적으로 전달 하 고는 DoWorkEventArgs 인스턴스.The method in turn raises the BackgroundWorker.DoWork event asynchronously and passes it a DoWorkEventArgs instance. 비동기 작업에서 값을 반환 하는 경우 BackgroundWorker.DoWork 이벤트 처리기는 일반적으로이 값 DoWorkEventArgs.Result 을 속성에 할당 합니다.If the asynchronous operation returns a value, the BackgroundWorker.DoWork event handler typically assigns it to the DoWorkEventArgs.Result property. 비동기 작업이 완료 되 면 합니다 BackgroundWorker.RunWorkerCompleted 이벤트가 발생 하 고 전달 되는 RunWorkerCompletedEventArgs (된 취소, 실패 또는 완료 여부 성공적으로) 작업의 상태에 대 한 정보를 포함 하는 인스턴스.When the asynchronous operation completes, the BackgroundWorker.RunWorkerCompleted event is raised and is passed a RunWorkerCompletedEventArgs instance that contains information about the status of the operation (whether it was cancelled, faulted, or completed successfully). 성공적으로 완료 되 면 해당 Result 비동기 작업에서 반환 하 고 이전에 할당 된 값을 포함 하는 속성을 DoWorkEventArgs.Result 속성입니다.If it completed successfully, its Result property contains the value returned by the asynchronous operation and previously assigned to the DoWorkEventArgs.Result property.

참고

합니다 HostProtectionAttribute 이 클래스에 적용 된 특성에는 다음과 같은 Resources 속성 값: SharedState합니다.The HostProtectionAttribute attribute applied to this class has the following Resources property value: SharedState. HostProtectionAttribute는 대개 아이콘을 두 번 클릭하거나, 명령을 입력하거나, 브라우저에서 URL을 입력하여 시작되는 데스크톱 애플리케이션에 영향을 미치지 않습니다.The HostProtectionAttribute does not affect desktop applications (which are typically started by double-clicking an icon, typing a command, or entering a URL in a browser). 자세한 내용은 참조는 HostProtectionAttribute 클래스 또는 SQL Server 프로그래밍 및 호스트 보호 특성합니다.For more information, see the HostProtectionAttribute class or SQL Server Programming and Host Protection Attributes.

생성자

RunWorkerCompletedEventArgs(Object, Exception, Boolean) RunWorkerCompletedEventArgs(Object, Exception, Boolean) RunWorkerCompletedEventArgs(Object, Exception, Boolean) RunWorkerCompletedEventArgs(Object, Exception, Boolean)

RunWorkerCompletedEventArgs 클래스의 새 인스턴스를 초기화합니다.Initializes a new instance of the RunWorkerCompletedEventArgs class.

속성

Cancelled Cancelled Cancelled Cancelled

비동기 작업이 취소되었는지 여부를 나타내는 값을 가져옵니다.Gets a value indicating whether an asynchronous operation has been canceled.

(Inherited from AsyncCompletedEventArgs)
Error Error Error Error

비동기 작업 중 발생한 오류를 나타내는 값을 가져옵니다.Gets a value indicating which error occurred during an asynchronous operation.

(Inherited from AsyncCompletedEventArgs)
Result Result Result Result

비동기 작업의 결과를 나타내는 값을 가져옵니다.Gets a value that represents the result of an asynchronous operation.

UserState UserState UserState UserState

사용자 상태를 나타내는 값을 가져옵니다.Gets a value that represents the user state.

메서드

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

지정한 개체와 현재 개체가 같은지 여부를 확인합니다.Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

기본 해시 함수로 작동합니다.Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

현재 인스턴스의 Type을 가져옵니다.Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.Creates a shallow copy of the current Object.

(Inherited from Object)
RaiseExceptionIfNecessary() RaiseExceptionIfNecessary() RaiseExceptionIfNecessary() RaiseExceptionIfNecessary()

비동기 작업에 실패한 경우 사용자가 제공한 예외를 발생시킵니다.Raises a user-supplied exception if an asynchronous operation failed.

(Inherited from AsyncCompletedEventArgs)
ToString() ToString() ToString() ToString()

현재 개체를 나타내는 문자열을 반환합니다.Returns a string that represents the current object.

(Inherited from Object)

적용 대상

추가 정보