Re: Threading to prevent GUI Freeze

2016-01-04 Thread Gerald via Digitalmars-d-learn
On Monday, 4 January 2016 at 18:04:34 UTC, TheDGuy wrote: On Monday, 4 January 2016 at 17:33:28 UTC, Gerald wrote: On Monday, 4 January 2016 at 16:13:50 UTC, TheDGuy wrote: [...] Yes, you need it. The extern (C) function is what GDK invokes on idle. In any GUI application there is a lot of

Re: Threading to prevent GUI Freeze

2016-01-04 Thread Ali Çehreli via Digitalmars-d-learn
On 01/04/2016 06:31 AM, TheDGuy wrote: > I tried it with "std.concurrency" like this: > > bool drawCallback(Scoped!Context cr, Widget widget){ > writeln("init"); > spawn(, cr, widget); The first parameter to render() is Scoped!Context but render() takes a Context: > void

Re: Threading to prevent GUI Freeze

2016-01-04 Thread Luis via Digitalmars-d-learn
On Monday, 4 January 2016 at 14:31:04 UTC, TheDGuy wrote: Hello, i use GTKD to draw some stuff on a DrawingArea. Because it needs some time to calculate i want to outsource those calculation so that the GUI doesn't freeze. I tried it with "std.concurrency" like this: bool

Re: Threading to prevent GUI Freeze

2016-01-04 Thread Gerald via Digitalmars-d-learn
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 :

Re: Threading to prevent GUI Freeze

2016-01-04 Thread TheDGuy via Digitalmars-d-learn
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

Re: Threading to prevent GUI Freeze

2016-01-04 Thread TheDGuy via Digitalmars-d-learn
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

Re: Threading to prevent GUI Freeze

2016-01-04 Thread TheDGuy via Digitalmars-d-learn
On Monday, 4 January 2016 at 17:33:28 UTC, Gerald wrote: On Monday, 4 January 2016 at 16:13:50 UTC, TheDGuy wrote: [...] Yes, you need it. The extern (C) function is what GDK invokes on idle. In any GUI application there is a lot of idle time waiting for events, what the addThreadIdle

Re: Threading to prevent GUI Freeze

2016-01-04 Thread Gerald via Digitalmars-d-learn
On Monday, 4 January 2016 at 16:13:50 UTC, TheDGuy wrote: Thanks for your example code. Do i need those extern (C) function? Yes, you need it. The extern (C) function is what GDK invokes on idle. In any GUI application there is a lot of idle time waiting for events, what the addThreadIdle