|
Is there any way to identify an event that came to an end,
that the event arrived at the End Sub?
Sorry for the misspelled because I can not speak English and used a translator to help me
Thank you
Jonatas Marques
|
|
|
|
|
Only if you put code in the end of the Sub that signals this in some way.
|
|
|
|
|
What I need to do is something like this
Private Sub btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn.Click
Here runs a function that checks if the btn.Click comes to an end and shoot another routine but this routine can only be triggered when the event comes to an end btn.Click Ex: after the end Sub
End Sub
|
|
|
|
|
Soooooo, in a single threaded environment, this is incredibly easy. Just call the method as the last line of your Click handler. That's a horrible button name, by the way.
Private Sub btn_Click(blah, blah) Handles btn.Click
...some code...
MyOtherMethod()
End Sub
|
|
|
|
|
Ok kkkk promise to fix the name of Button.
But I still have doubts is like MyOtherMethod () to do the check when Private Sub btn_Click (blah, blah) Handles btn.Click end its process
I'm trying to do is this
1 - click on the button
2 - click on the button triggers the event Private Sub btn_Click (blah, blah) Handles btn.Click
3 - The btn.Click event triggers the routine MyOtherMethod () the btn.Click however, have to continue running the remaining code
4 - MyOtherMethod () loop is waiting for the end of btn.Click
5 - When the event finished btn.Click, MyOtherMethod () loop that identifies that event ended btn.Click and runs a code that is out of the loop and ends
What i am not able to do is, call event btn.Click MyOtherMethod () and continue running the rest of the code, which waits btn.Click MyOtherMethod () finish to continue
and also I am not able to make the MyOtherMethod () identifies which ended btn.Click
thank you
Jonatas Marques
|
|
|
|
|
OK, you didn't get it. There is NO other code after the call to MyOtherMethod . That is the last thing that happens inside the event handler.
I serisouly doubt you need to go call some method, then have it wait on the rest of the code in the handler to finish. It WILL NOT ever finish until the method you called finishes itself.
It sounds as though you need to restructure what you're doing, synchronously, to avoid this situation. When you make a method call, the code that does the calling does NOT continue to run while the method is executing. The calling code completely stops and waits for the method called to return. This is called a "blocking call".
Also, event handlers should return inside of about 250 milliseconds. While your event handler code is exectuing, your UI is copmletely hung waiting for it. The user cannot click on anything in your app until the handler returns.
But, in any case, the ONLY way to do what you describe to is use threading and a WaitHandle to signal the other thread. So, your event handler gets called, and in it you kick off another thread.
What are you doing that you think you need to do this??
|
|
|
|