DoWorkEventArgs.Argument DoWorkEventArgs.Argument DoWorkEventArgs.Argument DoWorkEventArgs.Argument Property

Определение

Возвращает значение, представляющее аргумент асинхронной операции.Gets a value that represents the argument of an asynchronous operation.

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

Значение свойства

Объект Object, представляющий аргумент асинхронной операции.An Object representing the argument 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   

Применяется к

Дополнительно