Interval, Tick, Stop : Timer « Development Class « C# / C Sharp






Interval, Tick, Stop

  


using System;
using System.Drawing;
using System.Windows.Forms;
   
class CloseInFive: Form
{
     public static void Main()
     {
          Application.Run(new CloseInFive());
     }
     public CloseInFive()
     {
          Text = "Closing in Five Minutes";
   
          Timer timer    = new Timer();
          timer.Interval = 5 * 60 * 1000;
          timer.Tick    += new EventHandler(TimerOnTick);
          timer.Enabled  = true;
     }
     void TimerOnTick(object obj, EventArgs ea)
     {
          Timer timer = (Timer) obj;
   
          timer.Stop();
          timer.Tick -= new EventHandler(TimerOnTick);
   
          Close();          
     }
}

   
  








Related examples in the same category

1.Using TimerCallback
2.illustrates the use of the Timer classillustrates the use of the Timer class
3.Demonstrates using the System.Threading.Timer objectDemonstrates using the System.Threading.Timer object
4.Demonstrates using the System.Timers.Timer class 2Demonstrates using the System.Timers.Timer class 2
5.Control ModifierControl Modifier
6.Digital Clock with Date
7.Simple Clock
8.Timer.Elapsed
9.Test Timer