关于QueryPerformanceCounter的高精度计时器
我们可以用QueryPerformanceCounter实现一个高精度timer:
QueryPerformanceCounter c
while(true)
QueryPerformanceCounter c1
If c1 - c >= delay Then
QueryPerformanceCounter c
Call timer
End If
DoEvents
wend
但是这样的问题是cpu占用100%... 如果在循环里加上sleep(1)就能降低cpu占用 但是sleep的精度太低
sleep(1)大概sleep了16ms...
怎样才能在保证精度2ms的情况下降低cpu占用呢? 难道只能用多媒体定时器? 用QueryPerformanceCounter不行吗?