DoWorkEventHandler Delegate
Represents the method that will handle the DoWork event. This class cannot be inherited.
Assembly: System (in System.dll)
<HostProtectionAttribute(SecurityAction.LinkDemand, SharedState := True)> Public Delegate Sub DoWorkEventHandler ( sender As Object, e As DoWorkEventArgs )
Parameters
- sender
-
Type:
System.Object
The source of the event.
- e
-
Type:
System.ComponentModel.DoWorkEventArgs
A DoWorkEventArgs that contains the event data.
When you create a DoWorkEventHandler delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event-handler method is called whenever the event occurs, unless you remove the delegate. For more information about event-handler delegates, see NIB: Events and Delegates.
The following code example demonstrates how to use the DoWorkEventHandler delegate 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
Available since 10
.NET Framework
Available since 2.0
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0