Biblioteca de clases de .NET Framework
DoWorkEventArgs.Argument (Propiedad)

Nota: esta propiedad es nueva en la versión 2.0 de .NET Framework.

Obtiene un valor que representa el argumento de una operación asincrónica.

Espacio de nombres: System.ComponentModel
Ensamblado: System (en system.dll)

Sintaxis

Visual Basic (Declaración)
Public ReadOnly Property Argument As Object
Visual Basic (Uso)
Dim instance As DoWorkEventArgs
Dim value As Object

value = instance.Argument
C#
public Object Argument { get; }
C++
public:
property Object^ Argument {
    Object^ get ();
}
J#
/** @property */
public Object get_Argument ()
JScript
public function get Argument () : Object

Valor de propiedad

Objeto Object que representa el argumento de una operación asincrónica.
Ejemplo

En el ejemplo de código siguiente se muestra cómo utilizar la clase DoWorkEventArgs para controlar el evento DoWork. Para obtener una lista de código completa, vea Cómo: Ejecutar una operación en segundo plano.

Visual Basic
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   
C#
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;
    }
}
Plataformas

Windows 98, Windows 2000 SP4, Windows Millennium, Windows Server 2003, Windows XP Media Center, Windows XP Professional x64, Windows XP SP2, Windows XP Starter Edition

.NET Framework no admite todas las versiones de cada plataforma. Para obtener una lista de las versiones admitidas, vea Requisitos del sistema.

Información de versión

.NET Framework

Compatible con: 2.0
Vea también

Etiquetas :


Page view tracker