积极答复者
线程函数调用问题

问题
答案
-
取决您线程函数,比如您的线程的实现如下所示:
DWORD WINAPI ThreadProc(LPVOID lParam)
{
MSG msg;
BOOL bExitThread = FALSE;
while(!bExitThread && GetMessage(&msg, NULL, 0, 0))
{
switch(msg.message)
{
case MSG_DOSOMETHING: // 您可以利用PostThreadMessage给该线程发送消息,让线程做事情
// TODO:
break;
case MSG_EXIT: // 发送消息给线程,让线程退出
bExitThread = TRUE;
break;
default:
break;
}
}
return 0;
}
Visual C++ enthusiast, like network programming and driver development. At present is being engaged in the WinCE/Windows Mobile platform embedded development.
- 已编辑 VisualElevenModerator 2014年10月28日 15:15
- 已标记为答案 May Wang - MSFT 2014年10月31日 9:34
全部回复
-
你好,
你可以考虑用异步多线程模式实现。具体实现方式需要你先了解清楚里面的机制自己试着实现。
http://www.cnblogs.com/zjjcy/archive/2012/03/25/2416700.html
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey. -
取决您线程函数,比如您的线程的实现如下所示:
DWORD WINAPI ThreadProc(LPVOID lParam)
{
MSG msg;
BOOL bExitThread = FALSE;
while(!bExitThread && GetMessage(&msg, NULL, 0, 0))
{
switch(msg.message)
{
case MSG_DOSOMETHING: // 您可以利用PostThreadMessage给该线程发送消息,让线程做事情
// TODO:
break;
case MSG_EXIT: // 发送消息给线程,让线程退出
bExitThread = TRUE;
break;
default:
break;
}
}
return 0;
}
Visual C++ enthusiast, like network programming and driver development. At present is being engaged in the WinCE/Windows Mobile platform embedded development.
- 已编辑 VisualElevenModerator 2014年10月28日 15:15
- 已标记为答案 May Wang - MSFT 2014年10月31日 9:34