Async process - Start Subroutine when finished
Collapse
This topic is closed.
X
X
-
MarcolinoTags: None -
rowe_newsgroups
Re: Async process - Start Subroutine when finished
On Apr 8, 10:43 am, Marcolino <marco.pozzu... @gmail.comwrote :You can set up a callback from the BeginInvoke call that will fireHi 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
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.WriteLi ne("Starting")
Dim worker As New AsyncDelegate(A ddressOf AsyncMethod)
worker.BeginInv oke(New AsyncCallback(A ddressOf
AfterAsyncMetho d), Nothing)
Console.WriteLi ne("Asnyc called")
Console.Read()
End Sub
Private Sub AfterAsyncMetho d(ByVal ar As IAsyncResult)
Console.WriteLi ne("AsyncMetho d finished. Do something else")
End Sub
Private Sub AsyncMethod()
Console.WriteLi ne("Async is working")
'// Simulate work
System.Threadin g.Thread.Sleep( 1500)
Console.WriteLi ne("Async is done working")
End Sub
End Module
////////////////
Thanks,
Seth Rowe [MVP]
-
Spam Catcher
Re: Async process - Start Subroutine when finished
rowe_newsgroups <rowe_email@yah oo.comwrote in news:424eb9ff-3910-40c0-
8bda-91d0741e3030@e3 9g2000hsf.googl egroups.com:
Should call EndInvoke here - to clean up the Async handler?Private Sub AfterAsyncMetho d(ByVal ar As IAsyncResult)
Console.WriteLi ne("AsyncMetho d finished. Do something else")
End Sub
--
spamhoneypot@ro gers.com (Do not e-mail)
Comment
-
kimiraikkonen
Re: Async process - Start Subroutine when finished
On Apr 8, 5:43 pm, Marcolino <marco.pozzu... @gmail.comwrote :Marco,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 also play with BackgroundWorke r control and its events such as
RunWorkerComple ted, ProgressChanged events if it helps you.
Regards,
Onur Güzel
Comment
-
Marcolino
Re: Async process - Start Subroutine when finished
On 8 Apr, 18:50, kimiraikkonen <kimiraikkone.. .@gmail.comwrot e:Hi I tryed this:On Apr 8, 5:43 pm, Marcolino <marco.pozzu... @gmail.comwrote :
>>>Hi All,
I'm using this code provided by Michael to run Async process:>Now I have a new need. I have to start a Soubroutine when the Async
process is finished.>Many Thanks.>--Marco
Marco,
You can also play with BackgroundWorke r control and its events such as
RunWorkerComple ted, ProgressChanged events if it helps you.
>
Regards,
>
Onur Güzel
worker.BeginInv oke(New AsyncCallback(A ddressOf AfterAsyncMetho d),
Nothing)
but i have a little problem.
During sub AfterAsyncMetho d() i need to populate a listview present on
main form. This is not possible because I cannot execute cross tread
operation.
I need that AfterAsyncMetho d() will be executed on the main tread of
the application, after my async process is finished.
Thanks a lot
Comment
Comment