TCHAR szError[255];
HANDLE hTimer;
__int64 qwDueTime;
LARGE_INTEGER liDueTime;
/* ResvTimer */
if ( hTimer = CreateWaitableTimer(NULL, FALSE,"recvtimeTimer" ) )
{
// Create an integer that will be used to signal the timer
// 2 seconds from now.
qwDueTime = (-2) * _SECOND;
// Copy the relative time into a LARGE_INTEGER.
liDueTime.LowPart = (DWORD) ( qwDueTime & 0xFFFFFFFF );
liDueTime.HighPart = (LONG) ( qwDueTime >> 32 );
if (SetWaitableTimer(hTimer,&liDueTime,60000,RecvTimerProc,NULL,FALSE))
{
TRACE("Called the RecvTimerProc to set local time ./n");
while (RunFlag)
{
SleepEx(INFINITE,/* Wait forever*/TRUE /* Put thread in an alertable state*/);
}
}
else
{
wsprintf( szError, "SetWaitableTimer failed with Error %d.", GetLastError() );
MessageBox( NULL, szError, "Error", MB_ICONEXCLAMATION );
}
CloseHandle( hTimer ); // END of timer
}
一个定时器模型
最新推荐文章于 2024-10-14 14:38:43 发布
1221

被折叠的 条评论
为什么被折叠?



