Hello, I have the code below which will simply help you if you want to know the backgroundworkder in .net. So, just make use of it:
I
Code:
mports System.Threading
Public Class tee
Private Sub backgroundWorkerTesting(ByVal sender As Object, _
ByVal e As System.ComponentModel.DoWorkEventArgs) Handles bgw.DoWork
...........
End Sub
Private last As String, StartedAt As String
Private check As Boolean = False, show As Boolean
Private WithEvents bgw As New System.ComponentModel.BackgroundWorker
Public Sub startBackgroundTask()
check = True
StartedAt = "Started : " & Format(Now, "h:mm:ss") & "." & Now.Millisecond
bgw.RunWorkerAsync()
End Sub
Private Sub bgw_done(ByVal sender As Object, _
ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) _
Handles bgw.RunWorkerCompleted
check = False
last = "Ended : " & Format(Now, "h:mm:ss") & "." & Now.Millisecond
If show = True Then MsgBox(Timestamp, , "completed")
End Sub
Public ReadOnly Property Timestamp() As String
Get
Return StartedAt & Chr(13) & last
End Get
End Property
Public ReadOnly Property IsWorking() As Boolean
Get
Return check
End Get
End Property
Public Property getToKnow() As Boolean
Get
Return show
End Get
Set(ByVal value As Boolean)
show = value
End Set
End Property
End Class
Bookmarks