我的用户接口线程的Run()没反应了,但::GetExitCodeThread()函数返回的却是STILL_ACTIVE???求救!!!

weiyunfei 2003-08-19 05:37:14
我的Run():
int CLineThread::Run()
{
while(TRUE)
{
if (PeekMessage (&msg, 0, WM_NULL, WM_NULL, PM_REMOVE))
{
switch(msg.message)
{
//其它消息处理
default:break;
}
}
//记录日志
Sleep(10);
}
}
刚开始还能看到记的日志,过一段时间后就看不到了,我也跟踪不到线程究竟干什么去了,但其状态一直为STILL_ACTIVE,请教!
...全文
95 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
flinming 2003-08-19
  • 打赏
  • 举报
回复
当然是根据你得消息了msg.message看是什么消息在做事情了
weiyunfei 2003-08-19
  • 打赏
  • 举报
回复
但我怎么才能看到我的线程在干什么?我用记日志的办法根本跟踪不到。。
kingzai 2003-08-19
  • 打赏
  • 举报
回复
if you want to exit thread ,using an event
in the thread's ExitInstance, and waiting for it in the control app.
Here's some documentation on getting the exit code .

Retrieving the Exit Code of a Thread

To get the exit code of either the worker or the user-interface
thread, call the ::GetExitCodeThread function. For information about
this function, see the Win32 Programmer's Reference, Volume 3. This
function takes the handle to the thread (stored in the m_hThread data
member of CWinThread objects) and the address of a DWORD.

If the thread is still active, ::GetExitCodeThread will place
STILL_ACTIVE in the supplied DWORD address; otherwise, the exit code
is placed in this address.

Retrieving the exit code of CWinThread objects takes an extra step. By
default, when a CWinThread thread terminates, the thread object is
deleted. This means you cannot access the m_hThread data member
because the CWinThread object no longer exists. To avoid this
situation, do one of the following two things:

Set the m_bAutoDelete data member to FALSE. This allows the CWinThread
object to survive after the thread has been terminated. You can then
access the m_hThread data member after the thread has been terminated.
If you use this technique, however, you are responsible for destroying
the CWinThread object as the framework will not automatically delete
it for you. This is the preferred method.

15,471

社区成员

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

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