// timer.cs
// C:>csc /t:winexe timer.cs
// Well we want our program to be in a GUI window, so we need to inherit
// from Form, which is in the library 'System.Windows.Forms'.
class
SimpleWindow : System.Windows.Forms.Form
{
private System.Windows.Forms.Timer
Ticker;
private System.ComponentModel.IContainer
components;
private int i;
private void Ticker_Tick(object sender,
System.EventArgs e)
{
i++;
this.Text = "Tick: " + i;
}
// End of Ticker_Tick(..) this.Text = title;
// Window constructor
SimpleWindow()
{
i = 0;
this.components =
new System.ComponentModel.Container();
this.Ticker =
new System.Windows.Forms.Timer(this.components);
this.Ticker.Interval = 25;
this.Ticker.Tick +=
new System.EventHandler(this.Ticker_Tick);
Ticker.Enabled = true;
}
// Our program entry point.
static void
Main()
{
System.Windows.Forms.Application.Run(new
SimpleWindow());
}
}//
End of SimpleWindow Class |