DoWorkEventArgs Clase

Definición

Proporciona datos para el controlador de eventos 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
Herencia
DoWorkEventArgs
Herencia
DoWorkEventArgs

Ejemplos

En el ejemplo de código siguiente se muestra cómo utilizar la DoWorkEventArgs clase para controlar el DoWork evento.The following code example demonstrates how to use the DoWorkEventArgs class to handle the DoWork event. Para obtener una lista de código completa, vea Cómo: ejecutar una operación en segundo plano.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   

Constructores

DoWorkEventArgs(Object)

Inicializa una nueva instancia de la clase DoWorkEventArgs.Initializes a new instance of the DoWorkEventArgs class.

Propiedades

Argument

Obtiene un valor que representa el argumento de una operación asincrónica.Gets a value that represents the argument of an asynchronous operation.

Cancel
Cancel

Obtiene o establece un valor que indica si se debe cancelar el evento.Gets or sets a value indicating whether the event should be canceled.

(Heredado de CancelEventArgs)
Result

Obtiene o establece un valor que representa el resultado de una operación asincrónica.Gets or sets a value that represents the result of an asynchronous operation.

Métodos

Equals(Object)

Determina si el objeto especificado es igual que el objeto actual.Determines whether the specified object is equal to the current object.

(Heredado de Object)
GetHashCode()

Sirve como la función hash predeterminada.Serves as the default hash function.

(Heredado de Object)
GetType()

Obtiene el Type de la instancia actual.Gets the Type of the current instance.

(Heredado de Object)
MemberwiseClone()

Crea una copia superficial del Object actual.Creates a shallow copy of the current Object.

(Heredado de Object)
ToString()

Devuelve una cadena que representa el objeto actual.Returns a string that represents the current object.

(Heredado de Object)

Se aplica a

Consulte también