I thought of an alternative to WaitFor.
From the information @Erel has given us, the command is a return, so the code flow continues back to the caller. When the event occurs, it returns to the puntu where it was suspended.
To get a similar thing, I thought that when I raised the event I would have to call the same Sub that was suspended and let it start from the interrupted point. It's not easy but I found a solution that works.
I used my library to raise as the event the same sub that it generates the class. It works fine without DoEvents at WaitFor.
And you do not have to enter the code into another sub raised by the event
From the information @Erel has given us, the command is a return, so the code flow continues back to the caller. When the event occurs, it returns to the puntu where it was suspended.
To get a similar thing, I thought that when I raised the event I would have to call the same Sub that was suspended and let it start from the interrupted point. It's not easy but I found a solution that works.
B4X:
Sub ButtonMsgBox_Click
Dim MsgB As MessageBox
If Not(Sender Is MessageBox) Then
' Before
MsgB.Initialize(Activity,Me,"ButtonMsgBox_Click")
MsgB.NewMsgBox("What do you want?","Ask","Si","cancel","No")
Else
' After Click
MsgB = Sender
ToastResponse(MsgB.Response,"No Wait For")
End If
End Sub
I used my library to raise as the event the same sub that it generates the class. It works fine without DoEvents at WaitFor.
And you do not have to enter the code into another sub raised by the event