Basically I have here a Quicksort demo. I was asked to put some sort of delay before the next recursive call, for illustration purposes.
Code:
g_timeout_add_seconds(1, emit_func, SOME_DATA);
Code:
while(gtk_event_pending()){ // run next recursive call after a certain interval, wait for event.
gtk_main_iteration();
}
recursive_func(param);
Doesn't work. For some reason, the loop exists after gtk_main_iteration(), or maybe after some few calls to it.
I also tried:
Code:
while(flag){
gtk_main_iteration();
if(gtk_events_pending())
flag = FALSE;
}
with the same problem.
I'm thinking of doing maybe doing a brute loop using a global flag that will be toggled via a timeout function, and alternatively counting via a clock() construct. But I don't want to do that, particularly in GTK+. I'm trying to make things as event driven as possible as to not hog CPU resources.
Sleep() doesn't work either as the whole program just stops (or block?), literally without anything on the GUI when it's suppose to.