Re: Thread problem in Windows



Filipe Apostolo wrote:
Armin Burgmeier wrote:
        Glib::Thread *const opcWriterThread = Glib::Thread::create(
             sigc::mem_fun(this, &MyClass::ThreadTest), true);
         opcWriterThread->join();
        writing.run();
Joining a thread means waiting for it to finish. So you are waiting
for the thread here before running the dialog, which explains the
behaviour you are experiencing.

Try joining it afterwards, or make the thread non-joinable.

Armin

Thanks it worked, however the the main thread is sucked until the user
closes the window, how can I call it back without user interaction?

Use .show() instead of .run(). To close the Window when the thread finishes, you can set up an idle handler in the thread right before it exits, and in your handler (which will then be executed by the main thread), call .hide() on the dialog.

I think you can also use Glib::Dispatcher for the same task.

Armin


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]