有没有 关于c++ 多线程 定时器 相关讲解的
发布网友
发布时间:2022-04-29 16:53
我来回答
共1个回答
热心网友
时间:2023-10-20 19:45
HANDLE reThread;
DWORD reThreadId;
reThread=CreateThread(NULL,0,(LPTHREAD_START_ROUTINEDealThread,0,0,&reThreadId);//创建线程
DWORD WINAPI CALLBACK DealThread(LPVOID para)
{//使用线程,定时器
MSG msg;
PeekMessage(&msg,NULL,WM_USER,WM_USER,PM_NOREMOVE);
UINT timerid=SetTimer(NULL,1,1000,TimerProc); //设置定时器的时间为1s
BOOL bRet;
while( (bRet = GetMessage(&msg,NULL,0,0))!= 0)
{
if(bRet==-1)
{
// handle the error and possibly exit
}
else
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
//KillTimer(NULL,timerid);
return 0;
}
VOID CALLBACK TimerProc(HWND hwnd,UINT uMsg,UINT idEvent,DWORD dwTime)
{//定时器回调函数,在这个函数里面写检测病人信号的代码
}
热心网友
时间:2023-10-20 19:45
HANDLE reThread;
DWORD reThreadId;
reThread=CreateThread(NULL,0,(LPTHREAD_START_ROUTINEDealThread,0,0,&reThreadId);//创建线程
DWORD WINAPI CALLBACK DealThread(LPVOID para)
{//使用线程,定时器
MSG msg;
PeekMessage(&msg,NULL,WM_USER,WM_USER,PM_NOREMOVE);
UINT timerid=SetTimer(NULL,1,1000,TimerProc); //设置定时器的时间为1s
BOOL bRet;
while( (bRet = GetMessage(&msg,NULL,0,0))!= 0)
{
if(bRet==-1)
{
// handle the error and possibly exit
}
else
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
//KillTimer(NULL,timerid);
return 0;
}
VOID CALLBACK TimerProc(HWND hwnd,UINT uMsg,UINT idEvent,DWORD dwTime)
{//定时器回调函数,在这个函数里面写检测病人信号的代码
}
热心网友
时间:2023-10-20 19:45
HANDLE reThread;
DWORD reThreadId;
reThread=CreateThread(NULL,0,(LPTHREAD_START_ROUTINEDealThread,0,0,&reThreadId);//创建线程
DWORD WINAPI CALLBACK DealThread(LPVOID para)
{//使用线程,定时器
MSG msg;
PeekMessage(&msg,NULL,WM_USER,WM_USER,PM_NOREMOVE);
UINT timerid=SetTimer(NULL,1,1000,TimerProc); //设置定时器的时间为1s
BOOL bRet;
while( (bRet = GetMessage(&msg,NULL,0,0))!= 0)
{
if(bRet==-1)
{
// handle the error and possibly exit
}
else
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
//KillTimer(NULL,timerid);
return 0;
}
VOID CALLBACK TimerProc(HWND hwnd,UINT uMsg,UINT idEvent,DWORD dwTime)
{//定时器回调函数,在这个函数里面写检测病人信号的代码
}
热心网友
时间:2023-10-20 19:45
HANDLE reThread;
DWORD reThreadId;
reThread=CreateThread(NULL,0,(LPTHREAD_START_ROUTINEDealThread,0,0,&reThreadId);//创建线程
DWORD WINAPI CALLBACK DealThread(LPVOID para)
{//使用线程,定时器
MSG msg;
PeekMessage(&msg,NULL,WM_USER,WM_USER,PM_NOREMOVE);
UINT timerid=SetTimer(NULL,1,1000,TimerProc); //设置定时器的时间为1s
BOOL bRet;
while( (bRet = GetMessage(&msg,NULL,0,0))!= 0)
{
if(bRet==-1)
{
// handle the error and possibly exit
}
else
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
//KillTimer(NULL,timerid);
return 0;
}
VOID CALLBACK TimerProc(HWND hwnd,UINT uMsg,UINT idEvent,DWORD dwTime)
{//定时器回调函数,在这个函数里面写检测病人信号的代码
}