B4J Question Wait for

micro

Well-Known Member
Licensed User
Longtime User
Hi to all
The thread in Tutorial is too old form reply then i open a new thread.

This is a request for proper use of 'wait for' ... if possible
I have a multiply lay that i load on a main panel into a sub, each layout has a set of buttons, how i can use correctly 'wait for' until a button is pressed and return the Sender or Button.Tag?

Thanks
 

EnriqueGonzalez

Expert
Licensed User
Longtime User
Hi micro

The proper use for wait for in your case is to not use it at all. Wait for was created for async calls not for ui events.

Use normal subs for the buttons click event.

Also note that

B4X:
Dim b as button = sender

This should be your first line, always when using the the sender keyword.

Mmmmm, don't try to force wait for, it will only work once for every call, and it will erease any other previous call.
 
Upvote 0

micro

Well-Known Member
Licensed User
Longtime User
ok, solved.

B4X:
wait for  ritorna_completed(value as string)

.......

Sub btyes_Action
    Ritorna("si")
End Sub

Sub btno_Action
    Ritorna("no")
End Sub

Sub Ritorna(value As String)
    CallSubDelayed2(Me, "ritorna_completed", value)
End Sub

Thanks
 
Upvote 0
Top