Threading to prevent GUI Freeze

TheDGuy via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Jan 4 06:31:04 PST 2016


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:"


More information about the Digitalmars-d-learn mailing list