Re: Multi-threaded UI Freezes on GDK Call
- From: "Brian J. Tarricone" <bjt23 cornell edu>
- To: gtk-app-devel-list gnome org
- Subject: Re: Multi-threaded UI Freezes on GDK Call
- Date: Tue, 18 Dec 2007 16:25:11 -0800
Michael McCann wrote:
Michael R. Head wrote:
Does your special function take time to do its job? If so, then that
would be why. For example:
...
while(1) {
gdk_threads_enter();
sleep(1)
gdk_threads_leave();
sleep(10)
};
...
you'd freeze your app for a second every 10 seconds.
Ahh, ok. How else can I accomplish my goal, then? I need to give GTK the
lock, as I'm calling GDK from another function not in the main GTK loop.
I tried leaving out gdk_threads_enter()/leave() in the CPU-intensive
function, but X gives me errors.
Don't use gdk in the CPU-intensive function:
while(1) {
sleep(1);
do_time_consuming_task();
gdk_threads_enter();
update_ui();
gdk_threads_leave();
}
You may need to factor out some code, but this is the right (read: only)
way to do it if you don't want to block the UI.
-brian
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]