DoWorkEventArgs Class
Provides data for the DoWork event handler.
Assembly: System (in System.dll)
System.EventArgs
System.ComponentModel.CancelEventArgs
System.ComponentModel.DoWorkEventArgs
| Name | Description | |
|---|---|---|
![]() | DoWorkEventArgs(Object) | Initializes a new instance of the DoWorkEventArgs class. |
| Name | Description | |
|---|---|---|
![]() | Argument | Gets a value that represents the argument of an asynchronous operation. |
![]() | Cancel | Gets or sets a value indicating whether the event should be canceled.(Inherited from CancelEventArgs.) |
![]() | Result | Gets or sets a value that represents the result of an asynchronous operation. |
| Name | Description | |
|---|---|---|
![]() | Equals(Object) | Determines whether the specified object is equal to the current object.(Inherited from Object.) |
![]() | Finalize() | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.) |
![]() | GetHashCode() | Serves as the default hash function. (Inherited from Object.) |
![]() | GetType() | |
![]() | MemberwiseClone() | |
![]() | ToString() | Returns a string that represents the current object.(Inherited from Object.) |
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; } }
Available since 10
.NET Framework
Available since 2.0
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.


