您的位置:首页 > 其它

线程池的计时器

2012-09-27 22:17 148 查看
#include "stdafx.h"

#include <conio.h>

#include <iostream>

#include <algorithm>

#include <vector>

using namespace std;

void CALLBACK TimeoutCallback(PTP_CALLBACK_INSTANCE, PVOID pvContext, PTP_TIMER pTimer)

{

long* count = (long*)pvContext;

InterlockedIncrement(count);

cout << GetCurrentThreadId() << "," << *count << 's' << endl;

}

void WaitForKeyboard()

{

while(!_kbhit());

}

void main()

{

PTP_TIMER pTimer = NULL;

long local = 0;

pTimer = CreateThreadpoolTimer(&TimeoutCallback, &local, NULL);

FILETIME ft = {-1, 0};

SetThreadpoolTimer(pTimer, &ft, 100, 0);

WaitForKeyboard();

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: