vc++中不占CPU的延时方法:
int CtestThreadDlg:时延(int m)//参数为延时秒数 { HANDLE hTimer =,空; HANDLE hT [2]; LARGE_INTEGER liDueTime; 时间=liDueTime.QuadPart m * (-100000000),/, 10; 时间=hTimer CreateWaitableTimer (NULL,,真的,,_T(“卡脖子”)); hT [0],=, hTimer; if (hTimer !) { return 1; } if (! SetWaitableTimer (hTimer,,, liDueTime,, 0,,空,,空,,假)) { CloseHandle (hTimer); return 2; } DWORD lBusy; 做 { 时间=lBusy MsgWaitForMultipleObjects (1, hT,,假的,,0 xffff, QS_ALLINPUT); const MSG 味精; GetMessage ((LPMSG),和味精,,空,,0,0); DispatchMessage(和味精); },while (lBusy ==,(时间+ WAIT_OBJECT_0 1)); CloseHandle (hTimer); return 0; }