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
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to