[plt-scheme] Problem with teachpaks

From: John Clements (clements at brinckerhoff.org)
Date: Wed Jan 22 13:48:18 EST 2003

On Tuesday, January 21, 2003, at 01:41  PM, Jens Axel Søgaard wrote:

>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
> I have problems using gui.ss and draw.ss at the same time.
> As a project my students have made a snake game using
> only draw.ss. For extras I suggested they made a gui with
> a highscore and a new game button. Alas, there are something
> wrong.
>
> The following illustrates the problem. I am not able to click
> the button if the loop is on. Its on winxp version 203
> (but you probably guessed that since I use get-key-event).
>
> Is there a work around?
>
> ; advanced student language, draw.ss and gui.ss
>
> (define (call-back event)
>   (begin
>     (display "foo")
>     true))
>
> (define (loop)
>   (begin
>     (get-key-event)
>     (sleep-for-a-while 1)
>     (loop)))
>
> (start 100 100)
> (create-window (list (list (make-button "foo" call-back))))
> (loop)

Please, someone correct me if I'm wrong...

If sleep-for-a-while calls sleep, you'll be blocking the user's thread. 
  Furthermore, if your evaluation thread is the eventspace's handler 
thread, the callbacks queued by clicks on the button will never be 
handled (because your loop never finishes).  What about a call to 
sleep/yield instead?

HTH,

john clements

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/enriched
Size: 1368 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20030122/3b321894/attachment.bin>

Posted on the users mailing list.