On Apr 8, 10:43 am, Marcolino <marco.pozzu...@gmail.comwrote:
Hi All,
I'm using this code provided by Michael to run Async process:
http://groups.google.com/group/micro...languages.vb/b...
Now I have a new need. I have to start a Soubroutine when the Async
process is finished.
Many Thanks.
--Marco
You can set up a callback from the BeginInvoke call that will fire
when the async process finishes. Then you can do whatever you need
from that method:
Here's a quick console demo app:
////////////////
Option Strict On
Module Module1
Public Delegate Sub AsyncDelegate()
Sub Main()
Console.WriteLine("Starting")
Dim worker As New AsyncDelegate(AddressOf AsyncMethod)
worker.BeginInvoke(New AsyncCallback(AddressOf
AfterAsyncMethod), Nothing)
Console.WriteLine("Asnyc called")
Console.Read()
End Sub
Private Sub AfterAsyncMethod(ByVal ar As IAsyncResult)
Console.WriteLine("AsyncMethod finished. Do something else")
End Sub
Private Sub AsyncMethod()
Console.WriteLine("Async is working")
'// Simulate work
System.Threading.Thread.Sleep(1500)
Console.WriteLine("Async is done working")
End Sub
End Module
////////////////
Thanks,
Seth Rowe [MVP]