Page 1 of 1

I can't cancel my window when sleep-function is executed

Posted: Sun Jun 12, 2005 4:54 pm
by alex
I can't cancel my window when sleep-function is executed

Example:
(while (= 1 1) (sleep 60000) )

If I hit Ctrl-C, I must wait up to 60 sec
It is normal?

Posted: Sun Jun 12, 2005 6:14 pm
by Lutz
Only on UNIX it lets you break out during sleep. As a workaround try the following:

Code: Select all

(define (mysleep ms)
        (let (start (time-of-day))
        (while (> (+ start ms) (time-of-day)) (sleep 10))))
Lutz

This code will let you break out with Ctrl-C

ps: note that 'time-of-day' wraps around at midnight

Posted: Sun Jun 12, 2005 7:09 pm
by alex
Thank Your. I will try.

Posted: Sun Jun 12, 2005 8:39 pm
by alex
for WINDOWS it is the same as
(while (= 1 1) (sleep 10) )
It is right?