title: How to run a function in every 10 minutes with in the loop using c#?
body: <p>I have a loop that continuously run a function based on some condition.
  Now, I want to call that function every 10 minutes only within the loop.
  I am using Visual Studio 2005. My code is:</p>
  
  <pre><code>    while (boolValue == false)
      {
           Application.DoEvents();
           StartAction();    //i want to call this function for every 10 minutes only
      }
  </code></pre>
  
  <p>I am using the System.Timers, but it's not calling the function. I don't know what's wrong.</p>
  
  <p>My code is:</p>
  
  <pre><code>   public static System.Timers.Timer aTimer;
     while (boolValue == false)
     {
          aTimer = new System.Timers.Timer(50000);
          aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
          aTimer.AutoReset = false;
          aTimer.Enabled = true;
     }
  
     private static void OnTimedEvent(object source, ElapsedEventArgs e)
     {
          Application.DoEvents();
          StartAction();
     }
  </code></pre>