[Mono-dev] timer locks up interface..
Giovanni A. D.
virtualdarkness at gmail.com
Fri Jan 13 18:28:09 EST 2006
It works! :-) thanks again.
here is the code, just in case it could be useful to someone else..
-------------------------------------------------------------------------------------------------------------
using System;
using Gtk;
using Glade;
public class GladeApp
{
public static void Main (string[] args)
{
new GladeApp (args);
}
public GladeApp (string[] args)
{
Application.Init ();
Glade.XML gxml = new Glade.XML (null, "gui.glade", "window1", null);
gxml.Autoconnect (this);
button1.Clicked += OnClickButton1;
button2.Clicked += OnClickButton2;
timerSetup();
startTimer();
Application.Run ();
}
Int32 timecnt;
bool stopTimer;
[Glade.Widget]
Button button1;
[Glade.Widget]
Button button2;
[Glade.Widget]
Label label1;
// Connect the Signals defined in Glade
private void OnWindowDeleteEvent (object sender, DeleteEventArgs a)
{
Application.Quit ();
a.RetVal = true;
}
private void OnClickButton1 (object o, EventArgs e)
{
Console.WriteLine("Start");
startTimer();
}
private void OnClickButton2 (object o, EventArgs e)
{
Console.WriteLine("Stop");
stopTimer=true;
}
private bool doGlibTimer()
{
Console.WriteLine("- timer - "+timecnt.ToString());
label1.Text=timecnt.ToString();
timecnt++;
if (timecnt > 10) {
timecnt=1;
}
return !stopTimer;
}
private void timerSetup()
{
timecnt=1;
stopTimer=true;
}
private void startTimer() {
my_timer.Elapsed += new System.Timers.ElapsedEventHandler(doTimerClick);
if (stopTimer) {
stopTimer=false;
GLib.Timeout.Add (1000, new GLib.TimeoutHandler (doGlibTimer));
}
Console.WriteLine("Timer setup OK");
}
}
-------------------------------------------------------------------------------------------------------------
bye,
Giovanni.
More information about the Mono-devel-list
mailing list