зеркало из https://github.com/mono/mail-archives.git
99 строки
4.0 KiB
HTML
99 строки
4.0 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
|
<HTML>
|
|
<HEAD>
|
|
<TITLE> [Gtk-sharp-list] Responsive Applications
|
|
</TITLE>
|
|
<LINK REL="Index" HREF="index.html" >
|
|
<LINK REL="made" HREF="mailto:gtk-sharp-list%40lists.ximian.com?Subject=%5BGtk-sharp-list%5D%20Responsive%20Applications&In-Reply-To=459FE27F.1050703%40homechoice.co.uk">
|
|
<META NAME="robots" CONTENT="index,nofollow">
|
|
<META http-equiv="Content-Type" content="text/html; charset=us-ascii">
|
|
<LINK REL="Previous" HREF="007681.html">
|
|
<LINK REL="Next" HREF="007680.html">
|
|
</HEAD>
|
|
<BODY BGCOLOR="#ffffff">
|
|
<H1>[Gtk-sharp-list] Responsive Applications</H1>
|
|
<B>Felipe Almeida Lessa</B>
|
|
<A HREF="mailto:gtk-sharp-list%40lists.ximian.com?Subject=%5BGtk-sharp-list%5D%20Responsive%20Applications&In-Reply-To=459FE27F.1050703%40homechoice.co.uk"
|
|
TITLE="[Gtk-sharp-list] Responsive Applications">felipe.lessa at gmail.com
|
|
</A><BR>
|
|
<I>Sat Jan 6 13:31:28 EST 2007</I>
|
|
<P><UL>
|
|
<LI>Previous message: <A HREF="007681.html">[Gtk-sharp-list] Responsive Applications
|
|
</A></li>
|
|
<LI>Next message: <A HREF="007680.html">[Gtk-sharp-list] Is it possible to create a button using the Glade-2 gui creater - when needing a button with a pango markup text?
|
|
</A></li>
|
|
<LI> <B>Messages sorted by:</B>
|
|
<a href="date.html#7683">[ date ]</a>
|
|
<a href="thread.html#7683">[ thread ]</a>
|
|
<a href="subject.html#7683">[ subject ]</a>
|
|
<a href="author.html#7683">[ author ]</a>
|
|
</LI>
|
|
</UL>
|
|
<HR>
|
|
<!--beginarticle-->
|
|
<PRE>On 1/6/07, White Spirit <<A HREF="http://lists.ximian.com/mailman/listinfo/gtk-sharp-list">wspirit at homechoice.co.uk</A>> wrote:
|
|
><i> Matteo Bertozzi wrote:
|
|
</I>><i> > Why OnButtonClick() Code Freeze the GUI?
|
|
</I>><i> > and how i could correct it?
|
|
</I>><i>
|
|
</I>><i> The problem is here:
|
|
</I>><i>
|
|
</I>><i> > Gtk.Application.Invoke (delegate {
|
|
</I>><i> > Thread.Sleep(1800 + 3600);
|
|
</I>><i> > button.Label = "End Hard Work";
|
|
</I>><i> > });
|
|
</I>
|
|
Yes, the problem is there.
|
|
|
|
><i> The code in the event handler is already running in the GTK thread.
|
|
</I>><i> Your code attempts to pass the code to the GTK thread from within the
|
|
</I>><i> GTK thread.
|
|
</I>><i>
|
|
</I>><i> Gtk.Application.Invoke is only used within threads other than the GTK
|
|
</I>><i> thread (because GTK# is not 'threadsafe'). So, if you had a thread
|
|
</I>><i> called mythread, once that thread was started you would use
|
|
</I>><i> Gtk.Application.Invoke to access GTK objects safely.
|
|
</I>
|
|
In fact, you can use Gtk.Application.Invoke everywhere. As you said,
|
|
he's already on the GTK's thread, so Gtk.Application.Invoke just
|
|
executes the code right away.
|
|
|
|
The problem, in fact, is that he is using Thread.Sleep in the GTK's
|
|
thread, so this blocks the UI. If this sleep is simulating some work
|
|
being done, it should be put on a different thread like this:
|
|
|
|
// UNTESTED
|
|
Thread worker = new Thread(delegate {
|
|
Thread.Sleep(1800 + 3600);
|
|
// We're on a different thread, Gtk.Application.Invoke is mandatory
|
|
Gtk.Application.Invoke(delegate {
|
|
button.Label = "End Hard Work";
|
|
});
|
|
});
|
|
worker.Start();
|
|
|
|
--
|
|
Felipe.
|
|
</PRE>
|
|
|
|
<!--endarticle-->
|
|
<HR>
|
|
<P><UL>
|
|
<!--threads-->
|
|
<LI>Previous message: <A HREF="007681.html">[Gtk-sharp-list] Responsive Applications
|
|
</A></li>
|
|
<LI>Next message: <A HREF="007680.html">[Gtk-sharp-list] Is it possible to create a button using the Glade-2 gui creater - when needing a button with a pango markup text?
|
|
</A></li>
|
|
<LI> <B>Messages sorted by:</B>
|
|
<a href="date.html#7683">[ date ]</a>
|
|
<a href="thread.html#7683">[ thread ]</a>
|
|
<a href="subject.html#7683">[ subject ]</a>
|
|
<a href="author.html#7683">[ 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>
|