How to let Timer skip tick if the previous thread is still busy

后端 未结 8 1678
攒了一身酷
攒了一身酷 2020-12-01 11:28

I created a windows service, that is supposed to check a certain table in the db for new rows every 60 seconds. For every new row that was added, I need to do some heavy pro

8条回答
  •  佛祖请我去吃肉
    2020-12-01 11:38

    You don't need the lock in this case. Set timer.AutoReset=false before starting it. Restart the timer in the handler after you are done with your processing. This will ensure that the timer fires 60 seconds after each task.

提交回复
热议问题