interrupting a big loop



When my (gtk) app is engaged in a time-consuming loop process, I'd
like to offer the user the chance of breaking out if he/she loses
interest.  The pseudo-code is something like:

for (i=0; i<LARGE_NUMBER; i++) {
   if (break_condition()) break;
   /* do something complicated */
}

where "break_condition()" checks whether a particular quit key has
been pressed or quit button has been clicked.

My puzzle is over how exactly to link the break_condition() function
with the appropriate callback associated with the keystroke or
button-click.  Do I need something like g_main_context_iteration()?

Any gpointers gratefully received.

Allin Cottrell



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