how to continuously run a c# console application in background

前端 未结 4 397
醉梦人生
醉梦人生 2021-01-19 06:58

I would like to know how to run a c# program in background every five minute increments. The code below is not what I would like to run as a background process but would lik

4条回答
  •  迷失自我
    2021-01-19 07:04

    This app should run continuously, putting out a message every 5 minutes.
    Isn't that what you want?

    class Program
    {
        static void Main(string[] args)
        {
            while (true) {
                Console.Write("hellow world");
                System.Threading.Thread.Sleep(1000 * 60 * 5); // Sleep for 5 minutes
            }
    
        }
    }
    

提交回复
热议问题