newLISP Fan Club

Forum => newLISP in the real world => Topic started by: alex on June 12, 2005, 09:54:07 AM

Title: I can't cancel my window when sleep-function is executed
Post by: alex on June 12, 2005, 09:54:07 AM
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?
Title:
Post by: Lutz on June 12, 2005, 11:14:05 AM
Only on UNIX it lets you break out during sleep. As a workaround try the following:



(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
Title:
Post by: alex on June 12, 2005, 12:09:37 PM
Thank Your. I will try.
Title:
Post by: alex on June 12, 2005, 01:39:06 PM
for WINDOWS it is the same as  

  (while (= 1 1) (sleep 10) )

It is right?