As mentioned in this thread:
https://www.b4x.com/android/forum/t...r-asynchronous-programming.77867/#post-493180
"Sleep" is a new delay keyword that does not block the main app.
What would be real helpful is if it supported an additional/optional "abort" parameter:
This way we can include a Boolean variable when calling the routine that, when it's value becomes true, it will exit the sleep delay right away instead of waiting the full msDelay time:
This would allow us to response to certain external events right away and not have to wait for the sleep delay to complete.
There could also be a third optional "ExitWhenFalse" parameter for instances when you want to exit the sleep delay when a [global] variable turns false.
https://www.b4x.com/android/forum/t...r-asynchronous-programming.77867/#post-493180
"Sleep" is a new delay keyword that does not block the main app.
B4X:
Sleep(1000)
What would be real helpful is if it supported an additional/optional "abort" parameter:
B4X:
Sleep(msDelay as Int, ExitWhenTrue as Boolean)
This way we can include a Boolean variable when calling the routine that, when it's value becomes true, it will exit the sleep delay right away instead of waiting the full msDelay time:
B4X:
FTP.Download
Sleep (90000, DownloadCompleted)
This would allow us to response to certain external events right away and not have to wait for the sleep delay to complete.
There could also be a third optional "ExitWhenFalse" parameter for instances when you want to exit the sleep delay when a [global] variable turns false.
B4X:
Sleep(msDelay as Int, ExitWhenTrue as Boolean, ExitWhenFalse as boolean)
Last edited: