QueryPerformanceCounter:获取当前的高精度计时器值
QueryPerformanceFrequency:获取高精度计时器的频率
[DllImport("Kernel32.dll")] private static extern bool QueryPerformanceCounter(out long lpPerformanceCount); [DllImport("Kernel32.dll")] private static extern bool QueryPerformanceFrequency(out long lpFrequency); // 高精度睡眠函数 static void HighPrecisionSleep(int milliseconds) { long start = 0, stop = 0, frequency = 0; QueryPerformanceFrequency(out frequency); QueryPerformanceCounter(out start); long targetTicks = (frequency / 1000) * milliseconds; do { QueryPerformanceCounter(out stop); } while ((stop - start) < targetTicks); }
相当于 while(true) 到时了break;
标签:QueryPerformanceCounter,Windows,高精度,long,短且,frequency,计时器,out From: https://www.cnblogs.com/stweily/p/18601624