On Sat, 25 Jun 2016 23:35:11 GMT, dan hitt wrote:

On Wed, 22 Jun 2016 13:43:00 GMT, Gerald Nunn wrote:

On Tue, 21 Jun 2016 20:51:10 GMT, dan hitt wrote:

Can somebody point me to an example gtkd program that has an object of class Timeout in it?
.....

I use a timeout in but it's a fairly large code base rather then a simple example, hopefully it's of use anyway.

https://github.com/gnunn1/terminix/blob/master/source/gx/terminix/terminal/terminal.d

.....

I have one residual problem that i know of:
I tend to get messages of this form:

GLib-CRITICAL **: Source ID NNN was not found when attempting to remove it

and i'm not sure what to attribute it to, since d does its own garbage collection
(so i guess i'm already assuming this is a GC issue).

Just a little follow up on this:

First, the code i imitated from Gerald works perfectly as he presented it (earlier i was not being careful enough).

I do have the residual problem when i aggressively nest the Timeouts.

Ideally, i would like to be able to modify the timeout period of the Timeout when it fires, but it's not so clear how to do this: If i get recursive, and let each timer fire only once and start a new one with a different period, then, when i terminate the program i get a huge pile of these 'Source ID *** was not found when attempting to remove it' messages.

So what i did instead was to set the timeout period to be very short, but just not do my action each time. That is, i hacked in a little automaton that counts the number of times we've timed out, and does the action only each n times, where n gets smaller and smaller as time wears on.

This complete avoids the 'Source ID was not found ...' messages, but it is undesirable as it is polling behavior. Not polling in a tight loop, but nevertheless polling every 20 milliseconds or so.

So if anybody knows of a way to change the timeout period of a Timeout when it executes its delegate, please let me know.

And Gerald, thanks again for your help and showing your code. It puts my code in a much, much better state.