Using something like the code below the 'following code' in the 'CallingSub' is never executed and (of course) other code continues before the asynchronous call completes.
I really need to 'wait for' the asynchronous code to complete before continuing with the 'following code'
How do I do that?
Thanks
I really need to 'wait for' the asynchronous code to complete before continuing with the 'following code'
How do I do that?
Thanks
B4X:
Sub Class_Globals
Dim WiFi As MLwifi
End Sub
Sub CallingSub
Try
'Preceding code
'Call 'CalledSub' and wait for result
wait for (CalledSub) complete (Result As Boolean)
'returns with 'Result' not set?
'so following code never executes
Log("Following code")
Return Result
Catch
Log(LastException)
'e.g.: (NullPointerException) java.lang.NullPointerException
'etc
End Try
End Sub
Sub CalledSub As ResumableSub
'Call e.g.asynchronous code in a Library and wait for result
WiFi.reconnectWifiAP("SSID", 10000)
wait for Wifi_ConnectionResult(Success As Boolean) 'Returns immediately without return value set?
Return Success
End Sub