7,657
社区成员
发帖
与我相关
我的任务
分享
[DllImport("coredll.dll")]
extern static uint QueryPerformanceFrequency(ref long x);
[DllImport("coredll.dll")]
extern static uint QueryPerformanceCounter(ref long x);
long PERFORMANCE_FREQUENCY = 0;
QueryPerformanceFrequency(ref PERFORMANCE_FREQUENCY);
long t1 = 0, t2 = 0;
QueryPerformanceCounter(ref t1);
//Do the thing you want to do
QueryPerformanceCounter(ref t2);
double delay = (Convert.ToDouble(t2 - t1) * 1.0 / PERFORMANCE_FREQUENCY * 1000);//Delay time in ms