event based timer

maarten van damme maartenvd1994 at gmail.com
Wed Jul 20 05:00:23 PDT 2011


The problem with Sean Kelly's and the message sending approach is that when
using gtk I have to call Main.run(); and it pauses then untill the windows
are all closed. when I place a loop before Main.run() I never get a window
so If I want to use some kind of timer using threads I need to use shared?
(correct me if I'm wrong)

The glib.Timeout works like a charm, Thank you chris

2011/7/20 Sean Kelly <sean at invisibleduck.org>

> On Jul 19, 2011, at 3:19 AM, maarten van damme wrote:
>
> > Hi everyone,
> > for getting to know d a little bit I'm writing a simple pingpong game
> using gtk.
> > for it to work I need to be able to do something every 0.1 seconds so I
> was wondering if there was some kind of timer in the phobos library.
> > I've looked everywhere but couldn't find one. Is it missing and do i have
> to write my own or have I overlooked it?
>
> void loop() {
>    while( true ) {
>        doWhatever();
>        Thread.sleep(dur!"msecs"(100));
>    }
> }
>
> spawn(&loop);
>
>
> Or you could have the spawned thread send a message every 100 milliseconds,
> etc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20110720/be4916f5/attachment.html>


More information about the Digitalmars-d mailing list