Android Question sleep ? goto line or goto label ?

Devv

Active Member
Licensed User
Longtime User
Hi

is their is any library or way to do sleep in b4a without timer ?

the problem with timer is that it must continue to a different sub or it will repeat the sub the the beginning.

in java for example their is a sleep function is their is something like this for b4a ?

or is their is a go to label or go to line feature in b4a ?
 

TomA

Active Member
Licensed User
Longtime User
Although 'goto' is a reserved word in Java, it is not actually supported. See my posts at https://www.b4x.com/android/forum/threads/goto-one-day-in-b4a-as-in-b4ppc.17125/#post-136748 for more details on this (and why it is not in B4A.

As for 'sleep', depends what you want to do. If you just want the app to pause for a certain length of time, you can use something like:
B4X:
Sub WaitFor(Milliseconds As Int)
    Dim Present As Long
    Present = DateTime.Now
    Do While DateTime.Now < Present + Milliseconds
         DoEvents  
    Loop
End Sub
and call the sub for whatever period you want to program to sleep.
 
Upvote 0

RandomCoder

Well-Known Member
Licensed User
Longtime User
Be wary about using such routines as it will hammer the processor and consume battery power. It is better to use a timer wherever possible and stick with the event driven way of working. Maybe you could use a Select Case statement within the timed event to act as a GoTo type of function calling whichever sub you require?
 
Upvote 0
Top