Re: Infinite loop within a callback



On Mon, Apr 30, 2001 at 10:08:09AM +0200 Angelo Carpenzano wrote:

Hi,
I need to start an infinite loop when a toggle button receive the "toggled" event and I must to stop this 
loop when the is re-toggled.
If I write:

while(TRUE) {
   ...
}

I can't listen event and I can't stop the loop.
In addition to using threads, what a solution can I use?
Thanx,
Angelo Carpenzano


if you dont need any filedescriptors in your look (reading from file or
socket), then i would use 
gtk_idle_add(func) or gtk_timeout_add(ms, func).

func in gtk_idle_add is called from gtk if there are no other events that should be
processed. func in gtk_timeout_add is called every ms milliseconds.

If you want to do only some visual upadates in your loop, then use
for example gtk_timeout_add(500, func), because gtk_idle_add would be called
_much_ more often (depending on func).




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