mail-archives/gtk-sharp-list/2010-October/010534.html

125 строки
5.3 KiB
HTML
Исходник Постоянная ссылка Обычный вид История

2019-06-06 22:02:55 +03:00
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE> [Gtk-sharp-list] Simple Gtk window crash when Entry's text refreshed via a timer
</TITLE>
<LINK REL="Index" HREF="index.html" >
<LINK REL="made" HREF="mailto:gtk-sharp-list%40lists.ximian.com?Subject=%5BGtk-sharp-list%5D%20Simple%20Gtk%20window%20crash%20when%20Entry%27s%0A%09text%09refreshed%20via%20a%20timer&In-Reply-To=1286466235189-2967045.post%40n4.nabble.com">
<META NAME="robots" CONTENT="index,nofollow">
<META http-equiv="Content-Type" content="text/html; charset=us-ascii">
<LINK REL="Previous" HREF="010533.html">
<LINK REL="Next" HREF="010536.html">
</HEAD>
<BODY BGCOLOR="#ffffff">
<H1>[Gtk-sharp-list] Simple Gtk window crash when Entry's text refreshed via a timer</H1>
<B>Peter Johanson</B>
<A HREF="mailto:gtk-sharp-list%40lists.ximian.com?Subject=%5BGtk-sharp-list%5D%20Simple%20Gtk%20window%20crash%20when%20Entry%27s%0A%09text%09refreshed%20via%20a%20timer&In-Reply-To=1286466235189-2967045.post%40n4.nabble.com"
TITLE="[Gtk-sharp-list] Simple Gtk window crash when Entry's text refreshed via a timer">peter at peterjohanson.com
</A><BR>
<I>Thu Oct 7 11:57:42 EDT 2010</I>
<P><UL>
<LI>Previous message: <A HREF="010533.html">[Gtk-sharp-list] Simple Gtk window crash when Entry's text refreshed via a timer
</A></li>
<LI>Next message: <A HREF="010536.html">[Gtk-sharp-list] Simple Gtk window crash when Entry's text refreshed via a timer
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#10534">[ date ]</a>
<a href="thread.html#10534">[ thread ]</a>
<a href="subject.html#10534">[ subject ]</a>
<a href="author.html#10534">[ author ]</a>
</LI>
</UL>
<HR>
<!--beginarticle-->
<PRE>Andrea,
The System.Timers.Timer class fires it's events from a thread other than
the &quot;GUI thread&quot;, which causes issues with GTK+. You should use
GLib.Timeout.Add for this purpose.
See <A HREF="http://mono-project.com/Responsive_Applications">http://mono-project.com/Responsive_Applications</A> for further
information.
-pete
On Thu, Oct 07, 2010 at 08:43:55AM -0700, andrea wrote:
&gt;<i>
</I>&gt;<i> I've build a really simple application using MonoDevelop 2.4 in OpenSuse
</I>&gt;<i> (using VMWare image downloaded from mono website).
</I>&gt;<i>
</I>&gt;<i> My window contains a fixed container with an Entry widget named &quot;Entry1&quot;.
</I>&gt;<i>
</I>&gt;<i> Finally I modified autogenerated C# code in MainWindows.cs adding the
</I>&gt;<i> &quot;bolded&quot; code:
</I>&gt;<i>
</I>&gt;<i> using System;
</I>&gt;<i> using Gtk;
</I>&gt;<i> using System.Timers;
</I>&gt;<i>
</I>&gt;<i> public partial class MainWindow : Gtk.Window
</I>&gt;<i> {
</I>&gt;<i> Timer x=new Timer();
</I>&gt;<i>
</I>&gt;<i> public MainWindow () : base(Gtk.WindowType.Toplevel)
</I>&gt;<i> {
</I>&gt;<i> Build ();
</I>&gt;<i> x.Elapsed+=tmrElapsed;
</I>&gt;<i> x.Interval=500;
</I>&gt;<i> x.Enabled=true;
</I>&gt;<i> }
</I>&gt;<i>
</I>&gt;<i> private void tmrElapsed (object sender, ElapsedEventArgs e)
</I>&gt;<i> {
</I>&gt;<i> entry1.Text=DateTime.Now.ToString();
</I>&gt;<i> }
</I>&gt;<i>
</I>&gt;<i> protected void OnDeleteEvent (object sender, DeleteEventArgs a)
</I>&gt;<i> {
</I>&gt;<i> Application.Quit ();
</I>&gt;<i> a.RetVal = true;
</I>&gt;<i> }
</I>&gt;<i> }
</I>&gt;<i>
</I>&gt;<i> Finally I run it and I can see the window with the entry containing the
</I>&gt;<i> current date and time, but after 1 or 2 seconds the application crash
</I>&gt;<i> showing the trace attached ....
</I>&gt;<i>
</I>&gt;<i> What's wrong?
</I>&gt;<i>
</I>&gt;<i> Thanks in advance. <A HREF="http://mono.1490590.n4.nabble.com/file/n2967045/tmp.txt">http://mono.1490590.n4.nabble.com/file/n2967045/tmp.txt</A>
</I>&gt;<i> tmp.txt
</I>&gt;<i> --
</I>&gt;<i> View this message in context: <A HREF="http://mono.1490590.n4.nabble.com/Simple-Gtk-window-crash-when-Entry-s-text-refreshed-via-a-timer-tp2967045p2967045.html">http://mono.1490590.n4.nabble.com/Simple-Gtk-window-crash-when-Entry-s-text-refreshed-via-a-timer-tp2967045p2967045.html</A>
</I>&gt;<i> Sent from the Mono - Gtk# mailing list archive at Nabble.com.
</I>&gt;<i> _______________________________________________
</I>&gt;<i> Gtk-sharp-list maillist - <A HREF="http://lists.ximian.com/mailman/listinfo/gtk-sharp-list">Gtk-sharp-list at lists.ximian.com</A>
</I>&gt;<i> <A HREF="http://lists.ximian.com/mailman/listinfo/gtk-sharp-list">http://lists.ximian.com/mailman/listinfo/gtk-sharp-list</A>
</I>&gt;<i>
</I>
--
</PRE>
<!--endarticle-->
<HR>
<P><UL>
<!--threads-->
<LI>Previous message: <A HREF="010533.html">[Gtk-sharp-list] Simple Gtk window crash when Entry's text refreshed via a timer
</A></li>
<LI>Next message: <A HREF="010536.html">[Gtk-sharp-list] Simple Gtk window crash when Entry's text refreshed via a timer
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#10534">[ date ]</a>
<a href="thread.html#10534">[ thread ]</a>
<a href="subject.html#10534">[ subject ]</a>
<a href="author.html#10534">[ 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>