I need timer to rise event every 5 min but not only 5 min it must be on 00:00, 00:05, 00:10, 00:15 .... 23:55 and again 00:00.
我需要计时器每5分钟上升一次,但不仅仅需要5分钟,它必须在00:00,00:05,00:10,00:15 ...... 23:55再次00:00。
Server will send information every 5 min but when server started he need to calculate how many time is left until first rise of event, after that I cannot set 5 min interval because i lose like that every rise about 3-7 millisecond. so after few day's I lose lot of time. Because that I need to calculate every time rise of event after event is triggered. Because that I got in DB table with times (00:00, 00:05, ... 23:55) when server must rise event, also that table can be changed.
服务器将每隔5分钟发送一次信息,但是当服务器启动时,他需要计算在事件首次上升之前剩余的时间,之后我不能设置5分钟的间隔,因为我失去了每次上升大约3-7毫秒。所以几天之后我就失去了很多时间。因为我需要在事件触发后每次事件的上升时计算。因为当服务器必须上升事件时,我在DB表中有时间(00:00,00:05,... 23:55),也可以更改该表。
Anny suggestion will help.
Anny的建议会有所帮助。
1 个解决方案
#1
At the moment you're about to set the timer's intervall for the next time, you should read the system clock and calculate the remaining time to the next 5-Min "Tick"
在您下次要设置定时器的间隔时,您应该读取系统时钟并计算到下一个5分钟“Tick”的剩余时间
Example:
If it is 2:30:10 you should set an intervall of 4 Min, 50 seconds.
如果是2:30:10,你应设置4分50秒的间隔。
#1
At the moment you're about to set the timer's intervall for the next time, you should read the system clock and calculate the remaining time to the next 5-Min "Tick"
在您下次要设置定时器的间隔时,您应该读取系统时钟并计算到下一个5分钟“Tick”的剩余时间
Example:
If it is 2:30:10 you should set an intervall of 4 Min, 50 seconds.
如果是2:30:10,你应设置4分50秒的间隔。