зеркало из https://github.com/mono/mail-archives.git
104 строки
4.6 KiB
HTML
104 строки
4.6 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
|
<HTML>
|
|
<HEAD>
|
|
<TITLE> [Gtk-sharp-list] Force UI Update?
|
|
</TITLE>
|
|
<LINK REL="Index" HREF="index.html" >
|
|
<LINK REL="made" HREF="mailto:gtk-sharp-list%40lists.ximian.com?Subject=%5BGtk-sharp-list%5D%20Force%20UI%20Update%3F&In-Reply-To=BANLkTinPaHqNMJdeNT1myZ5_3X9qj44%3D1g%40mail.gmail.com">
|
|
<META NAME="robots" CONTENT="index,nofollow">
|
|
<META http-equiv="Content-Type" content="text/html; charset=us-ascii">
|
|
<LINK REL="Previous" HREF="010695.html">
|
|
<LINK REL="Next" HREF="010690.html">
|
|
</HEAD>
|
|
<BODY BGCOLOR="#ffffff">
|
|
<H1>[Gtk-sharp-list] Force UI Update?</H1>
|
|
<B>Jim Orcheson</B>
|
|
<A HREF="mailto:gtk-sharp-list%40lists.ximian.com?Subject=%5BGtk-sharp-list%5D%20Force%20UI%20Update%3F&In-Reply-To=BANLkTinPaHqNMJdeNT1myZ5_3X9qj44%3D1g%40mail.gmail.com"
|
|
TITLE="[Gtk-sharp-list] Force UI Update?">jim at va3hj.ca
|
|
</A><BR>
|
|
<I>Tue May 3 07:27:24 EDT 2011</I>
|
|
<P><UL>
|
|
<LI>Previous message: <A HREF="010695.html">[Gtk-sharp-list] Force UI Update?
|
|
</A></li>
|
|
<LI>Next message: <A HREF="010690.html">[Gtk-sharp-list] labelling a vbox - possible?
|
|
</A></li>
|
|
<LI> <B>Messages sorted by:</B>
|
|
<a href="date.html#10697">[ date ]</a>
|
|
<a href="thread.html#10697">[ thread ]</a>
|
|
<a href="subject.html#10697">[ subject ]</a>
|
|
<a href="author.html#10697">[ author ]</a>
|
|
</LI>
|
|
</UL>
|
|
<HR>
|
|
<!--beginarticle-->
|
|
<PRE>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
|
|
is blocking.
|
|
|
|
If it does end up bothering people, I can always redo the code as a
|
|
separate thread.
|
|
|
|
Jim
|
|
|
|
On 02/05/11 10:03 AM, Michael Hutchinson wrote:
|
|
><i> On Sun, May 1, 2011 at 4:29 PM, Jim Orcheson<<A HREF="http://lists.ximian.com/mailman/listinfo/gtk-sharp-list">jim at va3hj.ca</A>> wrote:
|
|
</I>>><i> I have a Gtk# application where the processing of a menu item may take
|
|
</I>>><i> many seconds. I want to change the cursor to a Watch before the actual
|
|
</I>>><i> processing takes place, and then change the cursor back to Arrow when
|
|
</I>>><i> done. For example:
|
|
</I>>><i>
|
|
</I>>><i> OnMenuItem(...)
|
|
</I>>><i> {
|
|
</I>>><i> DoSetupProcessing();
|
|
</I>>><i> this.GdkWindow.Cursor = new Gdk.Cursor(Gdk.CursorType.Watch);
|
|
</I>>><i> DoLongProcessing();
|
|
</I>>><i> this.GdkWindow.Cursor = new Gdk.Cursor(Gdk.CursorType.Arrow);
|
|
</I>>><i> }
|
|
</I>>><i>
|
|
</I>>><i> With this code the watch cursor is never displayed because UI updating
|
|
</I>>><i> normally only occurs during idle processing, which of course does not
|
|
</I>>><i> occur until after OnMenuItem returns.
|
|
</I>>><i>
|
|
</I>>><i> Is there a way to force the update to display the watch cursor without
|
|
</I>>><i> DoLongProcessing using a separate thread?
|
|
</I>><i> You could manually flush the UI event queue with
|
|
</I>><i> while (Gtk.Application.EventsPending ())
|
|
</I>><i> Gtk.Application.RunIteration ();
|
|
</I>><i> but your processing code will still be blocking the UI thread while
|
|
</I>><i> you're doing your processing, so if anything gets invalidated by an
|
|
</I>><i> external source it won't redraw.
|
|
</I>><i>
|
|
</I>><i> For a good user experience, you should really do the processing in a
|
|
</I>><i> thread, and probably show a modal dialog with a progress bar and a
|
|
</I>><i> cancel button. Your processing thread can update the progress bar
|
|
</I>><i> using Gtk.Application.Invoke to touch the UI thread.
|
|
</I>><i>
|
|
</I>><i> <A HREF="http://www.mono-project.com/Responsive_Applications">http://www.mono-project.com/Responsive_Applications</A>
|
|
</I>><i>
|
|
</I></PRE>
|
|
|
|
<!--endarticle-->
|
|
<HR>
|
|
<P><UL>
|
|
<!--threads-->
|
|
<LI>Previous message: <A HREF="010695.html">[Gtk-sharp-list] Force UI Update?
|
|
</A></li>
|
|
<LI>Next message: <A HREF="010690.html">[Gtk-sharp-list] labelling a vbox - possible?
|
|
</A></li>
|
|
<LI> <B>Messages sorted by:</B>
|
|
<a href="date.html#10697">[ date ]</a>
|
|
<a href="thread.html#10697">[ thread ]</a>
|
|
<a href="subject.html#10697">[ subject ]</a>
|
|
<a href="author.html#10697">[ author ]</a>
|
|
</LI>
|
|
</UL>
|
|
|
|
<hr>
|
|
<a href="http://lists.ximian.com/mailman/listinfo/gtk-sharp-list">More information about the Gtk-sharp-list
|
|
mailing list</a><br>
|
|
</body></html>
|