[Glade-users] uni- versus multi-threaded gtk

Hi guys,

I have written a c program with gtk builder user interface. The user presses a button which starts 
calculations and a graph to begin to be drawn. The calculations are very slow and so I want the user to be 
able to click a stop button to end it if they wish.

I've done it with multi-threading, so that the calculations are started in a new thread, leaving the ui still 
available for the user to click a button which changes the state of a flag. The calculations are within a 
while loop which keeps going or stops depending upon the state of the aforementioned flag.

But it seems crazy to me that I should need to do this simple thing with multi-threading.

I have this feeling there should be a way to do the computation within a while loop or something (without 
multi-threading) that is contingent upon receiving or not receiving a signal from a button. Sort of like:

while (! on_button_clicked) {

...compute stuff...


Can anyone give me advice here. Multi-threading seems to be overkill, and in fact, gives the user too much 
latitude to go off clicking other stuff I don't want them clicking. The ONLY thing the user need do while the 
program is working on the graph, is click a Stop button.


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