using System; using System.Windows.Forms; namespace MyForm { public class cForm1 : System.Windows.Forms.Form { public static int ctr =0; //declare... TextBox tb1, tb2; Timer ti; //<<<<<<<<< // react................. private void Animatio1 (object sender, EventArgs e){ //<<<<<<<<< System.Console.Write("hi! "); ctr++; if (ctr % 50==0) tb1.Text=ctr.ToString(); } public cForm1() { InitializeComponents(); //setup and delegate ti = new Timer(); //<<<<<<<<< ti.Interval = 1; //<<<<<<<<< ti.Enabled = true; //<<<<<<<<< // delegate timer-event to reacting function "animatio1"....... ti.Tick += new EventHandler (Animatio1); //<<<<<<<<< } void InitializeComponents() { // form this.Name = "form"; this.Text = "Halloiiiiiioooo!"; this.Size = new System.Drawing.Size(640, 400); // tb1 tb1 = new TextBox(); tb1.Name = "tb1"; tb1.Size = new System.Drawing.Size(200, 50); tb1.Location = new System.Drawing.Point(8, 100); this.Controls.Add(tb1); // tb2 tb2 = new TextBox(); tb2.Name = "tb2"; tb2.Size = new System.Drawing.Size(400, 10); tb2.Location = new System.Drawing.Point(8, 200); this.Controls.Add(tb2); tb2.Text="Input something: (the timer keeps going on): "; } // end class public class Mainframe { static public void Main() { Application.Run(new cForm1()); System.Console.WriteLine(123); } } // end class } // end namespace