how to continuously run a c# console application in background

前端 未结 4 399
醉梦人生
醉梦人生 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:20

    Probably the simplest way to "fire" a new process every X minutes is to use Windows Task Scheduler.

    You could of course do something similar programmatically, e.g. create your own service, that starts the console application every X minutes.


    All this under assumption you actually want to close the application before the next iteration. Alternatively, you might just keep it active the whole time. You might use one of the timer classes to fire events periodically, or even a Thread.Sleep in a very simplified scenario....

提交回复
热议问题