DoWorkEventArgs 클래스

정의

DoWork 이벤트 처리기에 대한 데이터를 제공합니다.Provides data for the DoWork event handler.

public ref class DoWorkEventArgs : System::ComponentModel::CancelEventArgs
public class DoWorkEventArgs : System.ComponentModel.CancelEventArgs
type DoWorkEventArgs = class
    inherit CancelEventArgs
Public Class DoWorkEventArgs
Inherits CancelEventArgs
상속
DoWorkEventArgs

예제

다음 코드 예제에서는 DoWorkEventArgs 클래스를 사용 하 여 DoWork 이벤트를 처리 하는 방법을 보여 줍니다.The following code example demonstrates how to use the DoWorkEventArgs class to handle the DoWork event. 전체 코드 목록은 방법: 백그라운드에서 작업 실행을 참조 하세요.For a full code listing, see How to: Run an Operation in the Background.

private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
    // Do not access the form's BackgroundWorker reference directly.
    // Instead, use the reference provided by the sender parameter.
    BackgroundWorker bw = sender as BackgroundWorker;

    // Extract the argument.
    int arg = (int)e.Argument;

    // Start the time-consuming operation.
    e.Result = TimeConsumingOperation(bw, arg);

    // If the operation was canceled by the user, 
    // set the DoWorkEventArgs.Cancel property to true.
    if (bw.CancellationPending)
    {
        e.Cancel = true;
    }
}
Private Sub backgroundWorker1_DoWork( _
sender As Object, e As DoWorkEventArgs) _
Handles backgroundWorker1.DoWork

   ' Do not access the form's BackgroundWorker reference directly.
   ' Instead, use the reference provided by the sender parameter.
   Dim bw As BackgroundWorker = CType( sender, BackgroundWorker )
   
   ' Extract the argument.
   Dim arg As Integer = Fix(e.Argument)
   
   ' Start the time-consuming operation.
   e.Result = TimeConsumingOperation(bw, arg)
   
   ' If the operation was canceled by the user, 
   ' set the DoWorkEventArgs.Cancel property to true.
   If bw.CancellationPending Then
      e.Cancel = True
   End If

End Sub   

생성자

DoWorkEventArgs(Object)

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

속성

Argument

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

Cancel
Result

비동기 작업의 결과 나타내는 값을 가져오거나 설정 합니다.Gets or sets a value that represents the result of an asynchronous operation.

메서드

Equals(Object)

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

(다음에서 상속됨 Object)
GetHashCode()

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

(다음에서 상속됨 Object)
GetType()

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

(다음에서 상속됨 Object)
MemberwiseClone()

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

(다음에서 상속됨 Object)
ToString()

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

(다음에서 상속됨 Object)

적용 대상

추가 정보