Maximum Timer interval

后端 未结 9 1283
心在旅途
心在旅途 2021-01-04 01:58

The maximum interval of timer is 2,147,483,647. it\'s about 25 days. But in my requirements I need that the timer will wait 30 days. How can I resolve it? Please help.

9条回答
  •  北荒
    北荒 (楼主)
    2021-01-04 02:15

    You can always have the timer wait a shorter amount of time, like one day and each time the timer fires increment a counter and check the current value of the counter. If the value is 30 then execute the code that is supposed to run once every 30 days.

    A better idea is to set the value some where in an external file so that if the program ever unexpectedly quits, you can resume where you left off. Ideally you'd probably want to put the next run date in the file, so that if the program is off for multiple days you can resume and have it fire on the correct date without having to worry about when the last time it ran. So something like

    NextRunDate = 10/10/2009 4:40 PM

    When the program runs it sets the date ahead another 30 days.

提交回复
热议问题