Timer.Tick : Timer « System.Timers « C# / C Sharp by API






Timer.Tick

  

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.new Timer()
2.new Timer(new TimerCallback(TimerHandler), null, 5000, 10000)
3.Timer.Elapsed
4.Timer.Interval