[Glade-users] uni- versus multi-threaded gtk
Russ Mannex
russ at mannex.com
Sat Jun 25 00:14:33 EDT 2011
Check out the documentation on the event loops. You want to do your
calculations inside an event loop. That way, if there's no event, it
keeps going. If there is an event, it can act on it.
--
Mannex
On Fri, 2011-06-24 at 20:18 -0700, David Buchan wrote:
> 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.
>
> Thanks,
> Dave
> _______________________________________________
> Glade-users maillist - Glade-users at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/glade-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/glade-users/attachments/20110624/aba325b3/attachment.html
More information about the Glade-users
mailing list