PDA

View Full Version : GUI thread and Working thread comunication



FasTTo
13th September 2007, 16:07
Hi everybody.

I have a very simple question that is stopping me from continue my project.

When I have a GUI thread and XX working threads, I know that I can emit signals from the working threads to the GUI thread, but, can I emit signals from the GUI thread to one of the working threads?
If yes, how can I do that?

Just to get an idea:
Imagine I have a file browser on the GUI and when I click on one file. This causes a parameters frame to be filled with a parameters form. Then, filled the parameters, I want to execute some actions on that file, based on the parameters. I want to do that in a separate working thread. How can that thread Know what file to process and the parameters to use?

wysota
13th September 2007, 16:31
Yes, you can emit signals both ways. Just emit a signal to an object that lives in the worker thread.

thomaspu
13th September 2007, 16:31
Well, If you are creating the working thread once you know the parameters, then just pass the parameters to the thread when you create it. So your pseudo code could be like:

<user clicks on a file>
Gui thread makes a file properties pane
gui thread looks at the file to see what properties it has
<at this point you know what file and what properties it has>
gui thread creates a worker thread and passes in a pointer to some info that contains details about what file and properties to work on.

Paul