How can i know whether the task in a tread is finished?

  • Thread starter Thread starter Norton
  • Start date Start date
N

Norton

I would like to wait for the task finish in that thread before exit the sub
, how can i achieve this?

thx in advance!


Public Overridable Sub Convert()
Try
oThread = New Thread(AddressOf ConvertThread)
oThread.Name = "SIS Data Coversion"
oThread.Start()

Catch ex As Exception
Throw New
Exception(System.Reflection.MethodBase.GetCurrentMethod.Name, ex)
End Try
End Sub
 
That would defeat the point of multithreading...
take a look at Invoking a method when your thread finishes.

Example: (untested)

Public Overridable Sub Convert()
Try
Thread = New Thread(AddressOf ConvertThread)
Thread.Name = "SIS Data Coversion"
Thread.Start()
Catch ex As Exception
Throw New
Exception(System.Reflection.MethodBase.GetCurrentMethod.Name, ex)
End Try
End Sub


Public Delegate Sub AfterThread()
Private Sub OnAfterThread()
'thread is done
End Sub


Sub ConvertThread
'do long process
Invoke(New AfterThread(AddressOf OnAfterThread))
End Sub


Hope it helps,

Cheers,
Lubos
 
Thx for your help!

can u tell me where can i find the Invoke method?
(a stupid question but donno which i should import to make it work :-p)

Thx
Norton
 
Back
Top