Android Question How this code work?

LucaMs

Expert
Licensed User
Longtime User
From this tutorial:
https://www.b4x.com/android/forum/t...ing-a-region-in-the-background.84767/#content

B4X:
              CallSubDelayed3(GeofenceService, "AddGeofence", Me, geo)
       Wait For Geofence_Added (Success As Boolean)
       Log("Geofence added: " & Success)
   End If
End Sub

As far as I know, CallSubDelayed will launch the routine AddGeofence only upon completion of the current routine.

Is that piece of code correct? And... "why"?


[I haven't tried that code; maybe I'll do it, just out of curiosity, it's interesting.]
 

LucaMs

Expert
Licensed User
Longtime User
Yes. You forgot rule #1 of resumable subs: a call to Wait For or Sleep is equivalent to a call to Return from the calling method perspective (calling method = the method that called this sub).
This is one of the few things my poor memory can remember :D:(.

The fact is that I assumed that CallSubDelayd could do its job only when executing the "End Sub" (and the code between these two commands).
 
Upvote 0
Top