我的线程为什么中止不了呢?很急!!!!!!!!!

cyh_enigma 2002-10-22 04:47:15
我线程的流程是:
UINT CMyClass::ThreadProc(LPVOID pParam)
{
CMyClass* myclass = (CMyClass*) pParam;
while( !(myclass->m_bStop)) //true)
{
........//My work
}
return 0;
}

void MyClass::StartThread()
{
CWinThread* pThread = AfxBeginThread(ThreadProc, this);
if (pThread!=NULL)
{
m_hThread = pThread->m_hThread;
m_bStop = false;
}
}

void MyClass::EndThread()
{
//终止线程
m_bStop = true;
WaitForSingleObject(m_hThread, INFINITE)
}
我在MyProjectAPP中调用EndThread(),我单步执行,程序一旦跳到这个函数中,好像整个程序都死了,线程卡在一个地方退不出来了,waitforsingleobject无限等待。为什么?哪会出问题呢?
...全文
21 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

15,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 进程/线程/DLL
社区管理员
  • 进程/线程/DLL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧