View Full Version : syncronous call function from other thread

26th June 2011, 11:54
I have the GUI Qthread and n workers Qthreads. I'm looking the way to do a syncronous call to a function that lives and must run on the GUI thread from the workers (with the minimun delay) and blocks the worker thread until is complete (about 20 ms).

With signals I've delays more than a second in process the signal. I try send events, but the call don't run on main thread.

What can be the best way to do this?

26th June 2011, 12:38
What signals semantics were you using? BlockingQueued?

Santosh Reddy
26th June 2011, 12:41
use Qt:: DirectConnection, while making a connection

26th June 2011, 12:44
use Qt:: DirectConnection, while making a connection

Then the slot will be executed in context of the worker thread and not the gui thread.

26th June 2011, 13:34
Now I implement it with two signals and two slots in Queued, one from worker to main, and when executed send another signal from main to worker to continue the work.

With BlockingQueue sometimes one thread finish in deadlock.

there any way to force the context??

26th June 2011, 13:51
If there is a deadlock then only because your code creates it, for example by doing a similar call the other way or blocking on a mutex.