How to write C# Scheduler

后端 未结 6 1508
故里飘歌
故里飘歌 2020-12-31 14:40

How do I write a Alert which will run at 00:00, 00:15, 00:30, and so on every day?

Can you give me an example code?

Thank you.

6条回答
  •  失恋的感觉
    2020-12-31 15:05

    You can use a timer that runs every minute that checks the current time. The check can look like:

    private void OnTimerTick()
    {
        if(DateTime.Now.Minutes%15==0)
        {
            //Do something
        }
    }
    

    But if you are looking for a program or service that has to be run every 15 minutes you can just write your application and have it started using a windows planned task.

提交回复
热议问题