Windows Service - How to make task run at several specific times?

前端 未结 4 356
醉话见心
醉话见心 2021-01-15 06:05

I have a windows service running. Within it the task runs currently at 7pm every day. What is the best way to have it run say fir example at 9.45am, 11.45am, 2pm, 3.45pm, 5p

4条回答
  •  生来不讨喜
    2021-01-15 06:58

    I would use a background thread and make it execute an infinite loop which does your work and sleeps for 15 minutes. It would be a lot cleaner and more simple for service code than using a timer.

    See this article on MSDN.

提交回复
热议问题