Threading to prevent GUI Freeze
Luis via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Jan 4 07:07:12 PST 2016
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 drawCallback(Scoped!Context cr, Widget widget){
> writeln("init");
> spawn(&render, cr, widget);
> return true;
> }
>
> void render(Context cr, Widget widget){
> Renderer renderer = new Renderer(new Vector3D(0,0,0), cr,
> widget);
> int i = 0;
> while(i < 4){
> renderer.renderOneStep();
> i++;
> }
> renderer.DisplayResult();
> }
>
> But i get:
>
> "std.concurrency.spawn(F, T...)(F fn, T args)
> if(isSpawnable!(F,T))"
> "Error: template std.concurrency.spawn cannot deduce function
> from argument types!()(void delegate(Context cr, Widget
> widget), Scoped Widget), candidates are:"
Before doing anything with threads and GTK, you should read this
:
http://blogs.operationaldynamics.com/andrew/software/gnome-desktop/gtk-thread-awareness
More information about the Digitalmars-d-learn
mailing list