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

Q&A's, tips, howto's
Locked
alex
Posts: 100
Joined: Thu Mar 10, 2005 2:27 pm
Location: Russia

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

Post 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?

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post 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

alex
Posts: 100
Joined: Thu Mar 10, 2005 2:27 pm
Location: Russia

Post by alex »

Thank Your. I will try.

alex
Posts: 100
Joined: Thu Mar 10, 2005 2:27 pm
Location: Russia

Post by alex »

for WINDOWS it is the same as
(while (= 1 1) (sleep 10) )
It is right?

Locked