On 22-06-18 15:36, Russel Winder wrote:

The example in demos/gtkD/DemoMultithread/DemoMultithread.d uses a C linkage function to create an idle listener on the GTK main loop. Is there a more D way of putting delegates on the main loop callback queue?

The demo way requires global data to communicate which somehow seems wrong.

You can use glib.Idle, which uses delegates.

As far as i can tell the gdk.Threads.threadsAddIdle function the demo
uses is compatible with the deprecated gdkthreadsenter/leave while
glib.Idle is not.

If you use gdkthreadsenter/leave in your application or if it's used
in one of the linked libraries, then it's safer to use
gdk.Threads.threadsAddIdle.