다음을 통해 공유


DoWorkEventArgs.Argument 속성

정의

비동기 작업의 인수를 나타내는 값을 가져옵니다.

public:
 property System::Object ^ Argument { System::Object ^ get(); };
public object Argument { get; }
public object? Argument { get; }
member this.Argument : obj
Public ReadOnly Property Argument As Object

속성 값

비동기 작업의 인수를 나타내는 Object입니다.

예제

다음 코드 예제를 사용 하는 방법을 보여 줍니다는 DoWorkEventArgs 이벤트를 처리 하는 클래스입니다 DoWork . 전체 코드 목록은 방법: 백그라운드에서 작업 실행을 참조하세요.

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

적용 대상

추가 정보