DoWorkEventArgs.Result 속성

정의

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

public:
 property System::Object ^ Result { System::Object ^ get(); void set(System::Object ^ value); };
public object Result { get; set; }
member this.Result : obj with get, set
Public Property Result As Object

속성 값

Object

비동기 작업의 결과를 나타내는 Object입니다.An Object representing the result of an asynchronous operation.

예제

다음 코드 예제에서는 클래스를 사용 하 여 이벤트를 처리 하는 방법을 보여 줍니다 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   

적용 대상

추가 정보