B4J Question Resumable Subs


Licensed User
I am watching the resumable subs vedio.

when wait for is introduced (in the vedio) I don't understand why control doesnt go to the button event handler the first time the button is clicked, but continues to execute all lines of code below the wait for.

I understand that a call to the Wait For keyword causes the sub to be paused and function returns until a certain event has been raised.

So I don't understand as the click event will still be fired when button was clicked for the first time

   Wait For Button_Click
   Log("I stole the click event...1")
   Log("I stole the click event...2")
   Log("I stole the click event...3")  
   Log("I stole the click event...4")
   Log("I stole the click event...5")
   Log("I stole the click event...6")

End SUb

Sub Button_Click
    Dim duration As Int = 500
    Button.SetLayoutAnimated(duration,0, MainForm.RootPane.Height - Button.PrefHeight, Button.PrefWidth, Button.PrefHeight)
End Sub

those 6 lnes below Wait For are executed when we click the button for the very first time but Button_Click is not called.

what exaclty is the flow of control ?

please help me to get my head around this.


Licensed User
Longtime User
Upvote 0