[Gtk-sharp-list] Pause the execution of crowded computation to allow the GUI to refresh
Adam Tauno Williams
awilliam at whitemice.org
Fri Apr 23 14:34:31 EDT 2010
On Fri, 2010-04-23 at 10:17 -0800, fpiraneo wrote:
> Adam Tauno Williams-3 wrote:
> > I'd just start the computation in a thread and update the progress bar
> > via Application.Invoke.
> ...and without using threading?
If you are just using a Glib.Timeout it won't work for a single threaded
app unless you occasionally release to the event loop.
You'd have to change your processing to periodically pause - that really
is all up to whatever processing you are doing. If it is an iteration
you should make sure you run the message queue every X number of loops.
Are you running your processing in an Idle handler?
Or you could do something of the following pattern:
void LongComputation ()
{
while (!done){
ComputationChunk ();
// Flush pending events to keep the GUI reponsive
while (Gtk.Application.EventsPending ())
Gtk.Application.RunIteration ();
}
}
<http://www.mono-project.com/Responsive_Applications>
This makes sure all the pending events are processed between chunks of your long computation.
--
Adam Tauno Williams <awilliam at whitemice.org> LPIC-1, Novell CLA
<http://www.whitemiceconsulting.com>
OpenGroupware, Cyrus IMAPd, Postfix, OpenLDAP, Samba
More information about the Gtk-sharp-list
mailing list