我使用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