How do you know when a thread is finished?
I need to create multiple threads on button click and I did it with this:
Dim myThread As New Threading.Thread(AddressOf getFile)
myThread.IsBackground = True
myThread.Start()
but i need to refresh the uploaded file window, buy if i set an event in getFile function and raise it to notify the files have been uploaded then refresh the image.
+2
a source to share
3 answers
Use an AsyncResult and check it periodically for completion, or provide a delegate to be called when the thread has finished.
A complete example in VB can be found here .
+7
a source to share
You can achieve what with Asyncallback, ...
Dim sinctotal As New Del_sinc(AddressOf sincronizar)
Dim ar As IAsyncResult = sinctotal.BeginInvoke(_funcion, type, New AsyncCallback(AddressOf SincEnd), cookieobj)
The cookieobj is
Class Cookie
Public id As String
Public AsyncDelegate As [Delegate]
Sub New(ByVal id As String, ByVal asyncDelegate As [Delegate])
Me.id = id
Me.AsyncDelegate = asyncDelegate
End Sub
End Class
When the delegate is done, it will call the Sincend function (in this example), then you can use an event to update your image.
Hope this helps!
+1
a source to share