how to have a function run inside a service every 10 minutes?

后端 未结 5 974
时光取名叫无心
时光取名叫无心 2021-02-01 11:16

I have a windows service running, inside this i want to run a function every then minutes. I have found some code but it doesn\'t seem to work? I have a logger and it does not s

5条回答
  •  不思量自难忘°
    2021-02-01 11:41

    Daniel Hilgarth is correct - the main issue is that you never call Start on the timer.

    That being said, you might want to also consider using the Windows Task Scheduler instead of a service with a timer. This allows you to schedule the task to run every 10 minutes, but also change the schedule whenever desired without a compilation change.

提交回复
热议问题