I'm just starting to try B4A and need to implement a sleep for eg. 1000 milliseconds. I looked at Timer, but it seems unsuitable for what I want. What I want is to simply have a call to sleep amongst other code. In Java one would just do "Thread.sleep(1000)" and it would probably be within a "Try" block.
I cannot find anything equivalent in B4A, and as I said the Timer does not appear to be appropriate for what I want. I would prefer to use standard B4A and the only way I could see to do that was the following:
That to me does not seem to be a good solution because it uses the CPU.
While it's easy to just put some inline Java code to do the "Thread.sleep()" I would prefer to use a B4A solution if there is one.
I cannot find anything equivalent in B4A, and as I said the Timer does not appear to be appropriate for what I want. I would prefer to use standard B4A and the only way I could see to do that was the following:
B4X:
Sub fn_SleepTill(lG_SleepEndMs As Long)
Do While (DateTime.Now < lG_SleepEndMs)
Loop
End Sub
That to me does not seem to be a good solution because it uses the CPU.
While it's easy to just put some inline Java code to do the "Thread.sleep()" I would prefer to use a B4A solution if there is one.