DoWorkEventArgs Class

 

Provides data for the DoWork event handler.

Namespace:   System.ComponentModel
Assembly:  System (in System.dll)

System.Object
  System.EventArgs
    System.ComponentModel.CancelEventArgs
      System.ComponentModel.DoWorkEventArgs

<HostProtectionAttribute(SecurityAction.LinkDemand, SharedState := True)>
Public Class DoWorkEventArgs
	Inherits CancelEventArgs

NameDescription
System_CAPS_pubmethodDoWorkEventArgs(Object)

Initializes a new instance of the DoWorkEventArgs class.

NameDescription
System_CAPS_pubpropertyArgument

Gets a value that represents the argument of an asynchronous operation.

System_CAPS_pubpropertyCancel

Gets or sets a value indicating whether the event should be canceled.(Inherited from CancelEventArgs.)

System_CAPS_pubpropertyResult

Gets or sets a value that represents the result of an asynchronous operation.

NameDescription
System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_pubmethodToString()

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

Universal Windows Platform
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.

Return to top
Show: