Updating Clock at a different rate to program loop-example not working as expected? - Printable Version +- QB64 Phoenix Edition (https://qb64phoenix.com/forum) +-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1) +--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3) +---- Forum: Help Me! (https://qb64phoenix.com/forum/forumdisplay.php?fid=10) +---- Thread: Updating Clock at a different rate to program loop-example not working as expected? (/showthread.php?tid=2946) |
Updating Clock at a different rate to program loop-example not working as expected? - dowster - 08-15-2024 Hi All, I hope this is an easy one for someone to point out my mistake. However I did find some reference to timer behaviour in windows that was different to Linux, so I tried this in Fedora, but both OSs ran the same. I found this example (I've modified it for QB64 timer only - didn't work as I expected with 'legacy' timer either). I expected that the clock would update at a rate of once per second, but that the A would be printed every 6 seconds (due to the sleep). However, if you run it the print A occurs every timer tick. What am I missing? Thanks! Code: (Select All)
RE: Updating Clock at a different rate to program loop-example not working as expected? - luke - 08-15-2024 Short answer: SLEEP is interrupted by timer events. This is mentioned in passing in the QB45 manual ("the program will stay suspended until ... an enabled event occurs") but appears to be missing from the QB64PE wiki. You can use _DELAY instead of SLEEP to achieve what you want (though note _DELAY cannot be interrupted by a keypress like SLEEP can). |