title: How to set timer in C#?
body: <p>I am making a program in C# that will ping "google" after every 15 minutes. If the ping is successful, it will then again check(ping) after 15 minutes and so on...If the ping is not successful, it will execute my ISP's dailer and will check again after every 15 minutes.</p>
  
  <p>I have written all the code but I can't seem to set the timer to repeat the code after every 15 minutes. If someone could help me, I would really appreciate it.</p>
  
  <p>This is the code.</p>
  
  <pre><code>using System;
  using System.Windows.Forms;
  using System.Net.NetworkInformation;
  using System.Net;
  using System.Diagnostics;
  
  namespace WindowsFormsApplication4
  {
  public partial class Form1 : Form
  {
      public Form1()
      {
          InitializeComponent();
      }
  
      private void Form1_Load(object sender, EventArgs e)
      {
          timer.Interval = (4000); //For checking, I have set the interval to 4 sec. It actually needs to be 15 minutes.
          timer.Enabled = true; 
          timer.Start(); 
  
          Ping ping = new Ping();
  
          PingReply pingStatus = ping.Send(IPAddress.Parse("208.69.34.231"));
  
          if (pingStatus.Status != IPStatus.Success)
          {
              timer.Tick += new EventHandler(timer1_Tick);
          }
  
      }
  
      private void timer1_Tick(object sender, EventArgs e)
      {
          Process.Start("C:\\WINDOWS\\system32\\rasphone.exe","-d DELTA1");
      }
  
  }
  }
  </code></pre>
  
  <p>What this code does is, if my dialer is already connected when I execute this program - it does nothing. Doesn't even recheck after 4 seconds.
  But if the dialer is not connected when I run this program, it connects my dialer instantly and tries to reconnect dialer after every 4 seconds without even checking(pinging google). </p>
  
  <p>I just can't seem to set the timer properly as I have never used the timer function before. I would really appreciate if someone could help me out.</p>
  
  <p>Regards,
  Shajee A.</p>