[Haskell-beginners] gtk2hs and threadDelay

Felipe Almeida Lessa felipe.lessa at gmail.com
Mon Dec 26 11:44:18 CET 2011


On Mon, Dec 26, 2011 at 8:33 AM,  <gabre at caesar.elte.hu> wrote:
> Thanks for the quick answers.
>
> I dont really know, what timer functions there are, I googled "timing,
> scheduling, delaying in haskell", but the only function I found, was
> threaddelay. How did you mean "adding a timer"?

This is Gtk+ stuff, since the main loop is there.  I'm talking about
using timeoutAdd [1].  Note that although the docs begin by saying
that the function is called at regular intervals, you just need to
make sure to return False to avoid that.

[1] http://hackage.haskell.org/packages/archive/glib/0.12.2/doc/html/System-Glib-MainLoop.html#v:timeoutAdd

> On the other side, I checked Graphics.UI.Gtk.Gdk.drawWindowProcessUpdates. I
> guess, I should use this in the function, where I draw something, and wait,
> and draw something else, and I should put it between the two drawing steps
> to get an immediate update. If I do so, the drawing gets blocked again, and
> nothing happens for some second, and then everything is drawn at the same
> time.

Even if you're able solve this particular problem, your application
still won't be processing events.  It will feel slugish and it's
possible that the window manager may decide that it has crashed.

Cheers,

-- 
Felipe.



More information about the Beginners mailing list