DoWorkEventArgs Klasa
Definicja
Ważne
Niektóre informacje odnoszą się do produktu w wersji wstępnej, który może zostać znacząco zmodyfikowany przed wydaniem. Firma Microsoft nie udziela żadnych gwarancji, jawnych lub domniemanych, w odniesieniu do informacji podanych w tym miejscu.
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
- Dziedziczenie
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 Instrukcje: uruchamianie operacji w tle.
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
| Nazwa | Opis |
|---|---|
| DoWorkEventArgs(Object) |
Inicjuje nowe wystąpienie klasy DoWorkEventArgs. |
Właściwości
| Nazwa | Opis |
|---|---|
| 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
| Nazwa | Opis |
|---|---|
| Equals(Object) |
Określa, czy określony obiekt jest równy bieżącemu obiektowi. (Odziedziczone po Object) |
| GetHashCode() |
Służy jako domyślna funkcja skrótu. (Odziedziczone po Object) |
| GetType() |
Pobiera Type bieżącego wystąpienia. (Odziedziczone po Object) |
| MemberwiseClone() |
Tworzy płytkią kopię bieżącego Object. (Odziedziczone po Object) |
| ToString() |
Zwraca ciąg reprezentujący bieżący obiekt. (Odziedziczone po Object) |