[Gtk-sharp-list] Simple Gtk window crash when Entry's text refreshed via a timer

andrea andrea at acquacontrol.it
Thu Oct 7 11:43:55 EDT 2010


I've build a really simple application using MonoDevelop 2.4 in OpenSuse
(using VMWare image downloaded from mono website).

My window contains a fixed container with an Entry widget named "Entry1".

Finally I modified autogenerated C# code in MainWindows.cs adding the
"bolded" code:

using System;
using Gtk;
using System.Timers;

public partial class MainWindow : Gtk.Window
{
	Timer x=new Timer();
	
	public MainWindow () : base(Gtk.WindowType.Toplevel)
	{
		Build ();
		x.Elapsed+=tmrElapsed;
		x.Interval=500;
		x.Enabled=true;
	}

	private void tmrElapsed (object sender, ElapsedEventArgs e)
	{
		entry1.Text=DateTime.Now.ToString();
	}	
	
	protected void OnDeleteEvent (object sender, DeleteEventArgs a)
	{
		Application.Quit ();
		a.RetVal = true;
	}
}

Finally I run it and I can see the window with the entry containing the
current date and time, but after 1 or 2 seconds the application crash
showing the trace attached ....

What's wrong?

Thanks in advance. http://mono.1490590.n4.nabble.com/file/n2967045/tmp.txt
tmp.txt 
-- 
View this message in context: http://mono.1490590.n4.nabble.com/Simple-Gtk-window-crash-when-Entry-s-text-refreshed-via-a-timer-tp2967045p2967045.html
Sent from the Mono - Gtk# mailing list archive at Nabble.com.


More information about the Gtk-sharp-list mailing list