brokeMyLegBiking
asked on
trigger an event in a parent thread
Is there a way to trigger an event in a parent thread while the child thread is still running?
I can call a method when the child thread finishes using the asynch callback, but not while its running.
Here is my attempt so far: (which is not working)
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim objmyAsynch As New my_asynch
Dim mi As New MethodInvoker(AddressOf objmyAsynch.my_asynch_sub)
mi.BeginInvoke(AddressOf mycallback_sub, Nothing)
End Sub
Public Sub mycallback_sub(ByVal ar As IAsyncResult)
Console.WriteLine("here")
Console.WriteLine(ar.Async State)
End Sub
Public Class my_asynch
Public Event myEvent()
Public Sub my_asynch_sub()
Console.WriteLine("second thread going just fine")
RaiseEvent myEvent()
End Sub
End Class
I can call a method when the child thread finishes using the asynch callback, but not while its running.
Here is my attempt so far: (which is not working)
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim objmyAsynch As New my_asynch
Dim mi As New MethodInvoker(AddressOf objmyAsynch.my_asynch_sub)
mi.BeginInvoke(AddressOf mycallback_sub, Nothing)
End Sub
Public Sub mycallback_sub(ByVal ar As IAsyncResult)
Console.WriteLine("here")
Console.WriteLine(ar.Async
End Sub
Public Class my_asynch
Public Event myEvent()
Public Sub my_asynch_sub()
Console.WriteLine("second thread going just fine")
RaiseEvent myEvent()
End Sub
End Class
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sorry about the B, guess it should be an A.
I'm just having trouble with threading. It's a big topic.
But I have opened up another question, perhaps you can answer this one?
https://www.experts-exchange.com/questions/21485361/trying-to-run-NET-START-command-using-ProcessStart.html
I'm just having trouble with threading. It's a big topic.
But I have opened up another question, perhaps you can answer this one?
https://www.experts-exchange.com/questions/21485361/trying-to-run-NET-START-command-using-ProcessStart.html
Thank you for the points