1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-08-04 17:40:24 +00:00
QB64-PE/tests/compile_tests/timer/sleep_ends_early.bas
Matthew Kilgore f995f38e38 Using Sleep with Console programs does not trigger timers
The command Sleep is supposed to allow timers to trigger while the
program is sleeping on the delay. This is achieved in QB64 by having
commands that do delays manually call evnt() to trigger events if they
come up (of which timers are one).

Sleep has a custom implementation for console programs on Windows which
doesn't do this, so I redid the logic so that it calls evnt() at regular
intervals while waiting for input. Additionally, due to now calling
evnt() we also need to check if we should exit sleep early due to an
evnt() firing.

Fixes: #294
2023-02-12 21:27:25 -05:00

14 lines
176 B
QBasic

$Console:Only
On Timer(2) GoSub timerhand
Timer On
' The timer triggering should end sleep early, so it only triggers once
Sleep 10
System
timerhand:
Print "Timer!"
return