timer 定时器

链接资料:

http://blog.csdn.net/yuntongsf/archive/2009/12/03/4936161.aspx

http://apps.hi.baidu.com/share/detail/18082112

 

个人代码:

// TimerExample.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include int _tmain(int argc, _TCHAR* argv[]) { HANDLE hTimer = CreateWaitableTimer(NULL, FALSE, NULL); if ( NULL == hTimer ) { printf("CreateWaitableTimer failed, error code is:%d/n",GetLastError()); return 0; } //when to start the timer. LARGE_INTEGER liDueTime; liDueTime.QuadPart = -100000000; //every 5 seconds , timer handle is signaled. LONG lPeriod = 5000; int iResult = SetWaitableTimer(hTimer, &liDueTime, lPeriod, NULL, NULL, FALSE); if ( iResult == 0 ) { printf("SetWaitableTimer failed. error code is:%d/n",GetLastError()); return 0; } while (TRUE) { iResult = WaitForSingleObject(hTimer, 10000); if ( WAIT_OBJECT_0 == iResult ) { printf("timer signaled./n"); } } CloseHandle(hTimer); return 0; }

。。。

你可能感兴趣的:(C/C++,timer,null,integer,object)