title: C# timers.timer is not working properly
body: <p>I'm trying to use a timer in C# to run a method at an interval of five seconds. Though this code doesn't seem to work. I do not get any errrors when running it but the program (I run this in a console) shuts down right after <code>IP.timer1.Start()</code>. The timer1_Elapsed method is never getting executed. I know that because I've tried making the program print a string to the console at the first line of the timer1_Elapsed method.</p>
  
  <pre><code>class Program
  {
      Timer timer1 = new Timer();
  
      static void Main(string[] args)
      {
          Program IP = new Program();
          IP.timer1.Elapsed += new ElapsedEventHandler(timer1_Elapsed);
          IP.timer1.Interval = 5000;
          IP.timer1.Enabled = true;
          IP.timer1.Start();
  
      }
  
      static void timer1_Elapsed(object sender, ElapsedEventArgs e)
      {
      //Function to get executed each time the counter elapses. 
      }
  
  }
  </code></pre>