[Gtk-sharp-list] Force UI Update?
jim at va3hj.ca
Tue May 3 07:27:24 EDT 2011
Thanks, that works.
I have avoided a separate thread because the processing in
DoLongProcessing() would only take a long time for a very few users, and
they would want that processing to complete before interacting with the
program in another way. Therefore I am not too concerned that the code
If it does end up bothering people, I can always redo the code as a
On 02/05/11 10:03 AM, Michael Hutchinson wrote:
> On Sun, May 1, 2011 at 4:29 PM, Jim Orcheson<jim at va3hj.ca> wrote:
>> I have a Gtk# application where the processing of a menu item may take
>> many seconds. I want to change the cursor to a Watch before the actual
>> processing takes place, and then change the cursor back to Arrow when
>> done. For example:
>> this.GdkWindow.Cursor = new Gdk.Cursor(Gdk.CursorType.Watch);
>> this.GdkWindow.Cursor = new Gdk.Cursor(Gdk.CursorType.Arrow);
>> With this code the watch cursor is never displayed because UI updating
>> normally only occurs during idle processing, which of course does not
>> occur until after OnMenuItem returns.
>> Is there a way to force the update to display the watch cursor without
>> DoLongProcessing using a separate thread?
> You could manually flush the UI event queue with
> while (Gtk.Application.EventsPending ())
> Gtk.Application.RunIteration ();
> but your processing code will still be blocking the UI thread while
> you're doing your processing, so if anything gets invalidated by an
> external source it won't redraw.
> For a good user experience, you should really do the processing in a
> thread, and probably show a modal dialog with a progress bar and a
> cancel button. Your processing thread can update the progress bar
> using Gtk.Application.Invoke to touch the UI thread.
More information about the Gtk-sharp-list