Link to home
Start Free TrialLog in
Avatar of brokeMyLegBiking
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.AsyncState)
    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
Avatar of Corey Scheich
Corey Scheich
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Do you need more info?  Did this pose some related questions?
Thank you for the points
Avatar of brokeMyLegBiking
brokeMyLegBiking

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