I made an example using a timer (MyLocation). I conduct a survey every second, everything is fine.
I tried using ResumableSub (MyLocation2).
Works only when in debug mode if you create a breakpoint on the line
B4X:
If gmap.MyLocation.IsInitialized Then
Applying a delay doesn't help. What am I doing wrong?
I think that your problem is that it is taking a while for your GPS to get a fix. Just waiting for 200ms may not be enough.
I would suggest that you add a log instead of reinitializing the timer, which is unnecessary.
That will tell you how many times the timer ticked before the location was available.
With the Wait for you only check once and if the location is not available then you stop. So that is the key difference.