Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'llamada al subproceso al hacer desde el proceso principal en el evento clic del botón
TestWorker = New System.ComponentModel.BackgroundWorker
TestWorker.WorkerReportsProgress = True
TestWorker.WorkerSupportsCancellation = True
TestWorker.RunWorkerAsync()
End Sub
Private Sub TestWorker_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles TestWorker.DoWork
Dim ListText As String
'Acción a realizar en el subproceso
For Value As Integer = 0 To 100
If TestWorker.CancellationPending Then
Exit For
End If
ListText = String.Concat("Item #", Value)
TestWorker.ReportProgress(Value, ListText)
'Retrasamos el hilo de ejecución
Threading.Thread.Sleep(100)
Next
End Sub
Private Sub TestWorker_RunWorkerCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles TestWorker.RunWorkerCompleted
MsgBox("Fin de la ejecución del subproceso")
End Sub
http://msdn.microsoft.com/es-es/library/system.componentmodel.backgroundworker(VS.95).aspx