[Gtk-sharp-list] System Time

Michael Hutchinson m.j.hutchinson at gmail.com
Sun Jul 16 14:55:15 EDT 2006

On 7/16/06, Attila Zilizi <zilo at wmx.sk> wrote:
> Hi all. I'm a beginner in programming.
> How is possible to display the system time on a label keeping updated
> every second?

Assuming that your label is called 'label', try

GLib.Timeout.Add (1000, delegate {
    label.Text = System.DateTime.Now.ToString ("t");
    return true;

This technique is the easiest way to do it in GTK#. Essentially,
GLib.Timeout.Add is used to add a delegate that should be called after
a given number of milliseconds (in this case, 1000ms, which is 1s).
The method returns true to indicate that it should be called again
when another 1000ms have elapsed.

Michael Hutchinson

More information about the Gtk-sharp-list mailing list