Threading to prevent GUI Freeze
Gerald via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Jan 4 07:59:50 PST 2016
On Monday, 4 January 2016 at 15:28:56 UTC, TheDGuy wrote:
> On Monday, 4 January 2016 at 15:07:12 UTC, Luis wrote:
>> On Monday, 4 January 2016 at 14:31:04 UTC, TheDGuy wrote:
>>> [...]
>>
>>
>> Before doing anything with threads and GTK, you should read
>> this :
>> http://blogs.operationaldynamics.com/andrew/software/gnome-desktop/gtk-thread-awareness
>
> Okay, so i have to do it like this on every function i use from
> GTKD?
>
> threadsInit();
> threadsEnter();
> GtkAllocation size;
> widget.getAllocation(size);
> threadsLeave();
I wrote a demo for GtkD showing how multi-threading and D work
together, it's in the demos/gtkD/DemoMultithread folder of GtkD,
hopefully it will be helpful. However this example it is based on
using the GTk threadIdle callback which is generally preferred
over the locking methods you show above, obviously though your
use case may vary but keep in mind the locking methods have been
deprecated, see the GTK 3 reference manual here:
https://developer.gnome.org/gdk3/stable/gdk3-Threads.html
You also see this GtkD issue here for
https://github.com/gtkd-developers/GtkD/issues/137 for some code
on how to use Delgates with gdk_threads_add_idle (i.e. GtkD
gdk.Threads.threadsAddIdle).
More information about the Digitalmars-d-learn
mailing list