The 'Sleep' and 'Wait For' are great facilities but I am now finding that I need to use Javascript style completion callbacks to process results from a Sub that uses one or other of them. I don't know if this suggestion would easily map onto the 'Wait For' mechanism but it would simplify the program flow if I could use
which would wait until Sub PerformSearch had properly returned.
B4X:
Wait For PerformSearch
B4X:
Sub btnPlace_Click
...
PerformSearch(PlaceList, "PlaceSearchComplete")
' Wait For PerformSearch ' I would like to do this
... ' presently I can't put completion code here or it runs too soon
End Sub
Sub PlaceSearchComplete
Dim Status As String = "Found " & ResultList.Size & " Place"
If ResultList.Size <> 1 Then Status = Status & "s"
SetStatus(Status, Colors.Black)
End Sub
Sub PerformSearch(Data As List, Callback As String)
If edtSearch.Text = "" Then
Msgbox2Async("No search term provided!", "Error", "OK", "", "", Null, True)
Wait For Msgbox_Result(Result As Int)
CallSub(Me, Callback)
Return
End If
... ' might do a Sleep or two here to update the UI
CallSub(Me, Callback)
End Sub