Re: GTK app misbehaving. (main thread blocking)
- From: Paul Pogonyshev <pogonyshev gmx net>
- To: gtk-app-devel-list gnome org, Alexander Markley <alex cybermalex com>
- Subject: Re: GTK app misbehaving. (main thread blocking)
- Date: Sat, 24 Apr 2004 23:38:28 +0300
Tim Müller wrote:
On Saturday 24 April 2004 17:25, Alexander Markley wrote:
I've got a button and a status-bar. I connect a callback to the button's
'clicked' event. The callback does A) a lot of work unrelated to GTK,
and B) updates the status-bar with the current progress.
In my mind, this should work. Except, while the callback is doing its
work, the main GTK window is completely frozen. The status bar doesn't
get updated, and the application window doesn't redraw. (If I cover the
window then reveal it, it stays blank.)
So my question is this: What is the correct way of doing bunches of work
when a signal is emitted without locking up the main thread?
You have two options:
(a) run
while (gtk_events_pending())
gtk_main_iteration_do(FALSE);
[...]
(b) hook up an idle timeout with g_idle_add (work_func, work_data)
[...]
And
(c) Start a new thread. A CPU-intensive task is the best reason to start
a new thread (non-blocking IO can be done with GIOChannels and without
threads).
Paul
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]