[plt-scheme] Re: Multitasking

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Tue Mar 24 12:51:47 EDT 2009

Using `thread' seems fine, but I recommend triggering an update by
calling `refresh' on a canvas instead of `on-paint'. Calling `refresh'
queues a refresh event for the canvas, which will be handled in the
GUI's main thread. Calling `on-paint' directly from a thread, in
contrast, means that your `on-paint' might run in two threads at the
same time.

At Mon, 23 Mar 2009 23:30:37 +0100, Peter Ngo wrote:
> Well i got it to work with a (thread ...) finally.
> But I'm still curious to see how you guys would do it ;)
> 2009/3/23 Peter Ngo <pngo23 at gmail.com>:
> > I was wondering how you would manage multitasking with Scheme,
> > e.g:
> > adding some bitmap objects in a list with a delay of 2 seconds
> > and repaint the canvas showing the modifications in real time(?).
> >
> > I thought about the timer% class which would
> > do a (send canvas on-paint) as a notify-callback but it didnt seem good to 
> me.
> >
> > Would it be better with (thread lambda() ....) ( which i don't really
> > understand ...) ?
> > Or is there a way to use events/handlers?
> > I didn't learn anything about events except for changing the canvas%
> > class in scheme/gui to cope with mouse events...

Posted on the users mailing list.