How to execute the loop for specific time

May be the following will help:

  Stopwatch s = new Stopwatch();
  s.Start();
  while (s.Elapsed < TimeSpan.FromSeconds(600)) 
  {
      //
  }

  s.Stop();

Leave a Comment