On Mon, 19 Nov 2018 22:20:48 GMT, adnan wrote:

On Mon, 19 Nov 2018 22:25:39 +0100, Mike Wey wrote:

On 19-11-2018 21:51, adnan wrote:

Hello I have to use parallel tasks for my application.
This involves creating a command line process and parsing a file created by the said process every half a second.

On the GDK side the thread init/enter/leave functions are deprecated,
and all UI calls into gtk should be made from the UI thread.

In that case you would use core.thread from druntime for your threading,
and setup a glib.Timeout to update the UI based on some shared state.

I see you are creating a new Timeout inside the loop, while glib.Timeout
will be called from the GTK mainloop, with at least the timeout between
calls, until it returns true. So you wouldn't want to do this in a loop.

Okay, I'm trying to achieve this with

        trigger.addOnClicked(delegate void(Button _) {


            auto sourceFileName = fcb.getFilename();
            auto deviceName = parseDeviceName(deviceCombo.getActiveText());

            auto ddCall = new Calldd(sourceFileName, deviceName);
            import std.parallelism : task;

            auto proc = task(&ddCall.dd);

            import glib.Timeout : Timeout;
            import gtkc.gtktypes : GPriority;

            auto timeout = new Timeout(500, delegate bool() {
                auto percentage = ddCall.parse();

                if (percentage == 0.0)
                else if (percentage == 100.0)

                    return false;
                        writefln("Percentage: %s", percentage);
                return true;

            }, GPriority.HIGH);

However, once the the proc starts in a new thread and when the inputs are set insensitive, the timeout doesn't seem to update? I put a writefln in debug mode too, it prints nothing. And the timeout keeps running forever. What could be causing this?

nvm fixed it. my parser wasn't right.