What's Here?
- Members: 300,322
- Replies: 825,548
- Topics: 137,368
- Snippets: 4,417
- Tutorials: 1,147
- Total Online: 2,007
- Members: 121
- Guests: 1,886
|
Enables to take advantage of multi-possessors.
|
Submitted By: m2s87
|
|
Rating:
 
|
|
Views: 22,160 |
Language: VB.NET
|
|
Last Modified: January 10, 2007 |
Instructions: Save it in a new class file
Write your code to the BackgroundWorker1_DoWork protsedure.
deklelare it like:
Dim x As New tee
start it like:
x.startBackgroundTask() |
Snippet
'written by Margus Martsepp AKA m2s87
Imports System.Threading
Public Class tee
Private Sub BackgroundWorker1_DoWork(ByVal sender As Object, _
ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
' Add your code here
End Sub
Private EndedAt As String, StartedAt As String
Private tegutseb As Boolean = False, Notifieonend As Boolean
Private WithEvents BackgroundWorker1 As New System.ComponentModel.BackgroundWorker
Public Sub startBackgroundTask() ' This will start the backgroundworker
tegutseb = True
StartedAt = "Started : " & Format(Now, "h:mm:ss") & "." & Now.Millisecond
BackgroundWorker1.RunWorkerAsync()
End Sub
Private Sub BackgroundWorker1_RunWorkerCompleted(ByVal sender As Object, _
ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) _
Handles BackgroundWorker1.RunWorkerCompleted ' Compleated
tegutseb = False
EndedAt = "Ended : " & Format(Now, "h:mm:ss") & "." & Now.Millisecond
If Notifieonend = True Then MsgBox(Timestamp, , "Protsess Done")
End Sub
Public ReadOnly Property Timestamp() As String
Get
Return StartedAt & Chr(13) & EndedAt
End Get
End Property
Public ReadOnly Property IsWorking() As Boolean
Get
Return tegutseb
End Get
End Property
Public Property Notifie_on_end() As Boolean
Get
Return Notifieonend
End Get
Set(ByVal value As Boolean)
Notifieonend = value
End Set
End Property
End Class
Copy & Paste
|
|
|
|