-6

I have the code below as an example, but would like to know how i could run the console .exe file indefinitely but run the for loop on five minute increment..

class Program
{
    static void Main(string[] args)
    {                
        for (int i = 0; i < 10; i++)
        {
            Console.WriteLine("hellow world");                    
        }
        Console.ReadLine();
    }
}
Lion
  • 18,729
  • 22
  • 80
  • 110
user2543131
  • 41
  • 1
  • 1
  • 3

2 Answers2

2

Take a look at Thread.Sleep:

Thread.Sleep(300000);

Where the number is the number of milliseconds you want to wait. I wouldn't recommend using a console application to do this though. Have you looked at creating a windows service?

Abe Miessler
  • 82,532
  • 99
  • 305
  • 486
1

I would run it as a Windows Scheduled Task. This way you don't have to re-implement all the scheduling options in your own application. So, the steps would be:

  1. Write a simple console application that executes your logic once and then exits
  2. Create a Scheduled Task to run your application at regular intervals. (Documentation is here)
Mike Marshall
  • 7,788
  • 4
  • 39
  • 63