我使用Threading.Timer,如:Threading.Timer麻烦
new System.Threading.Timer(
new System.Threading.TimerCallback(x=>
file.Write(DateTime.Now.ToString())
), null, 0, 600000);
而且,例如,它开始于11:00:00,然后我得到的文件:
11:00 :00
11时10分〇〇秒
11时二十零分00秒
...
12点10分〇〇秒
12时19分59秒
12时29分59秒
为什么?从某个时候开始做这样的事情? 我试过其他计时器,如Timers.Timer和winforms Timer,情况也是如此。 令人沮丧。
编辑:解决方案与精确定位器发布在线程中,没有帮助。 怎么样的win32多媒体计时器,它可以帮助吗?
看看这个看看http://stackoverflow.com/questions/897108/how-reliable-are-net-timers和这个http://stackoverflow.com/questions/5015255/reliable-alternative-to-timer- in-net-framework有帮助。 – gideon 2011-04-07 07:33:52
另请参阅:[为什么.NET定时器限制为15毫秒分辨率?](http://stackoverflow.com/questions/3744032/why-are-net-timers-limited-to-15-ms-resolution) – 2011-04-07 08:01:41