[問題] Multimedia Timer 超時的問題

作者: licheer (Keep The Faith)   2019-01-11 14:15:20
開發平台(Platform): Windows7
編譯器(Ex: GCC, clang, VC++...) VC++
mmtimer的時間間隔設為2ms,其中故意放一個會超時的工作 > 2ms
以MFC Timer來看, 時間就是被打亂而已
但mmtimer會被影響,不只是本身的UI會卡住,連同Windows也會跟著卡住
請問有大大知道為什麼會這樣嗎?
謝謝
const int timePeriod = 2;
const int timeRes = 1;
void CALLBACK TimeEvent
(UINT uTimerID, UINT uMsg, DWORD dwUser, DWORD dw1, DWORD dw2)
{
for (int i=0; i<999999; i++)
{
}
}
作者: Schottky (順風相送)   2019-01-11 16:07:00
把時間間隔改回預設值就不會了。那個timeBeginPeriod()是罪惡的根源,它把系統時間中斷從每秒18.2次加速到每秒500次,整個 Windows 效能自然悲劇。
作者: licheer (Keep The Faith)   2019-01-11 23:23:00
因為某一次測試時,發生整個Windows都卡住原本用MFC Timer或是 C# Timer, 即便超時也只是拉長間隔沒料到mmtimer會這麼嚴重
作者: Schottky (順風相送)   2019-01-12 01:18:00
你把 timeBeginPeriod() 那行刪掉就什麼事都沒有了

Links booklink

Contact Us: admin [ a t ] ucptt.com