DoWorkEventArgs Klasa

Definicja

Dostarcza dane dla programu obsługi zdarzeń DoWork .

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
Dziedziczenie
DoWorkEventArgs
Dziedziczenie
DoWorkEventArgs

Przykłady

W poniższym przykładzie kodu pokazano, jak używać DoWorkEventArgs klasy do obsługi DoWork zdarzenia. Aby uzyskać pełną listę kodu, zobacz How to: Run an Operation in the Background (Instrukcje: uruchamianie operacji w tle).

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

Konstruktory

DoWorkEventArgs(Object)

Inicjuje nowe wystąpienie klasy DoWorkEventArgs.

Właściwości

Argument

Pobiera wartość reprezentującą argument operacji asynchronicznej.

Cancel

Dostarcza dane dla programu obsługi zdarzeń DoWork .

Cancel

Pobiera lub ustawia wartość wskazującą, czy zdarzenie powinno zostać anulowane.

(Odziedziczone po CancelEventArgs)
Result

Pobiera lub ustawia wartość reprezentującą wynik operacji asynchronicznej.

Metody

Equals(Object)

Określa, czy dany obiekt jest taki sam, jak bieżący obiekt.

(Odziedziczone po Object)
GetHashCode()

Służy jako domyślna funkcja skrótu.

(Odziedziczone po Object)
GetType()

Type Pobiera wartość bieżącego wystąpienia.

(Odziedziczone po Object)
MemberwiseClone()

Tworzy płytkią kopię bieżącego Objectelementu .

(Odziedziczone po Object)
ToString()

Zwraca ciąg reprezentujący bieżący obiekt.

(Odziedziczone po Object)

Dotyczy

Zobacz też