// waitabletimer.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <Windows.h>
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
HANDLE hTimer;
LARGE_INTEGER perTime;
perTime.QuadPart=-1000000;
hTimer=CreateWaitableTimer(NULL,FALSE,NULL);//自动重置
SetWaitableTimer(hTimer,&perTime,1000,NULL,NULL,TRUE);//1000代表每个1秒发送一个信号,如果为0则只发送一次信号
while (1)
{
WaitForSingleObject(hTimer,INFINITE);
cout<<"主线程时间到了\n";
}
cin.get();
return 0;
}