btGo_Click
Wait For(StartScan) Complete (Result As Object)[
...
Sub StartScan As ResumableSub
For i = StartAt To EndAt Step Stap
Module1.SendTrimValue(i)
servosetting=i
lblServoSettings.Text=i
Sleep(interval*1000)
Next
Return Null
End Sub
The app is waiting for the scan to finish.
When the connection is broken, the app keeps waiting.
How can I stop the wait for?
The "index pattern" is a pattern that you can see in many examples and libraries where resumable subs are used. It is a simple solution to avoid race conditions and unexpected states. The resumable subs code like all other standard B4X code, is executed by the main thread. Still, with resumable...
Erel, Thanks for the lesson.
It is not quit what I was looking for, but in the meantime I found a solution...
B4X:
btGo_Click
Wait For(StartScan) Complete (Result As Object)
If Result=Not(False) Then
...
Sub StartScan As ResumableSub
For i = StartAt To EndAt Step Stap
If Not(Main.bt_connected) Then
MsgboxAsync(LastException.Message,"Oops...")
Return False
End If
Module1.SendTrimValue(i)
servosetting=i
lblServoSettings.Text=i
Sleep(interval*1000)
Next
Return Null
End Sub