title: Execute method every specific time(ms)
body: <p>I want to execute a method takes inputs every specific time (such as 25 ms) under the following conditions:</p>
  
  <ol>
  <li>run the method every 25 ms.</li>
  <li>If the method delay was greater than 25 ms, stop execution and start from the beginning for the new inputs.</li>
  </ol>
  
  <p>Hint: I used the following code but it doesn't stopped the execution if the method delay > 25 ms</p>
  
  <pre><code>private Timer timer1; 
  public void InitTimer()
  {
     timer1 = new Timer();
     timer1.Tick += new EventHandler(timer1_Tick);
     timer1.Interval = 1000/40; 
     timer1.Start();
  }
  
  private void timer1_Tick(object sender, EventArgs e)
  {
     mymethod()
  }    
  </code></pre>
  
  <p>Thanks</p>