It turned out there was a Timer in glib and glib is a part of gtk(I think). When you use gtkd you have acces to glib and that worked but it takes 50 procent of my cpu. (this was actually pretty strange. It worked fast and good untill I rebooted. Now it runs prety slow)<div>
and I don't think you can trigger a gtk event on a timer.<br><br><div class="gmail_quote">2011/7/20 Sean Kelly <span dir="ltr"><<a href="mailto:sean@invisibleduck.org">sean@invisibleduck.org</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Is there a timer function built into gtk?  Or can you have a separate thread trigger a gtk event on a timer?<br>
<div><div></div><div class="h5"><br>
On Jul 20, 2011, at 5:00 AM, maarten van damme wrote:<br>
<br>
> 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)<br>

><br>
> The glib.Timeout works like a charm, Thank you chris<br>
><br>
> 2011/7/20 Sean Kelly <<a href="mailto:sean@invisibleduck.org">sean@invisibleduck.org</a>><br>
> On Jul 19, 2011, at 3:19 AM, maarten van damme wrote:<br>
><br>
> > Hi everyone,<br>
> > for getting to know d a little bit I'm writing a simple pingpong game using gtk.<br>
> > 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.<br>
> > 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?<br>
><br>
> void loop() {<br>
>    while( true ) {<br>
>        doWhatever();<br>
>        Thread.sleep(dur!"msecs"(100));<br>
>    }<br>
> }<br>
><br>
> spawn(&loop);<br>
><br>
><br>
> Or you could have the spawned thread send a message every 100 milliseconds, etc.<br>
><br>
<br>
</div></div></blockquote></div><br></div>