Re: [gtk-list] Managing long operations in a single-threaded application



Monday Aug 23 20:56:19 -0700 1999 Arthur Jerijian <lightmanaj@earthlink.net> wrote:
> Hi all,
> 
> I need to perform a long operation, on the order of seconds or minutes, without
> freezing the entire GTK-based GUI that I'm using. This operation has no
> knowledge of GTK or its event messaging paradigm. Is there a way to perform
> this operation while still processing GTK messages in just one thread?

There are 2 possibilities:

1) Organize your code so, that you can return from it from time to time
and use gtk_idle_add() to return to the operation. In this case you must
put all local variables that you want to keep their value into a separate
structure that is given to the idle function as an argument.

2) Every now and then, do:
	while (gtk_events_pending())
               gtk_main_iteration();

See GTK tutorial and GTK faq for more information.	

> 
> Thanks,
> --Arthur

Tomi



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