DoWorkEventArgs Class

Definition

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

public ref class DoWorkEventArgs : EventArgs
public ref class DoWorkEventArgs : System::ComponentModel::CancelEventArgs
public class DoWorkEventArgs : EventArgs
public class DoWorkEventArgs : System.ComponentModel.CancelEventArgs
type DoWorkEventArgs = class
    inherit EventArgs
type DoWorkEventArgs = class
    inherit CancelEventArgs
Public Class DoWorkEventArgs
Inherits EventArgs
Public Class DoWorkEventArgs
Inherits CancelEventArgs
Inheritance
DoWorkEventArgs
Inheritance
DoWorkEventArgs

Examples

다음 코드 예제에서는 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   

Constructors

DoWorkEventArgs(Object)

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

Properties

Argument

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

Cancel
Cancel

이벤트를 취소 해야 할지 여부를 나타내는 값을 가져오거나 설정 합니다.Gets or sets a value indicating whether the event should be canceled.

(Inherited from CancelEventArgs)
Result

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

Methods

Equals(Object)

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

(Inherited from Object)
GetHashCode()

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

(Inherited from Object)
GetType()

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

(Inherited from Object)
MemberwiseClone()

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

(Inherited from Object)
ToString()

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

(Inherited from Object)

Applies to

See also