程序中使用了一个辅助线程,被搞晕了。
               
                  m_pSubThread = AfxBeginThread(CaptureData,this);
DWORD lpExitCode;
GetExitCodeThread(m_pSubThread->m_hThread,&lpExitCode);
if ( lpExitCode == STILL_ACTIVE)
                    {  ... }
发现这样用的时候辅助线程如果没异常的话程序也能正常运行,但是如果我自己的线程函数CaptureData如果遇到问题返回了,没办法得到返回值,这个lpExitCode总是259,怎么回事?
我在CaptureData中定义了一些返回code,对应不同的错误,可是没办法得到,有人知道怎么做吗?

解决方案 »

  1.   

    If the specified thread has not terminated, the termination status returned is STILL_ACTIVE. If the thread has terminated, the termination status returned may be one of the following: The exit value specified in the ExitThread or TerminateThread function. 
    The return value from the thread function. 
    The exit value of the thread's process.
      

  2.   

    ls说的我也看了,这样的话要得到自己定义的code怎么办呢?
      

  3.   

    WaitForSignalObject确认CaptureData线程已退出,然后GetExitCodeThread取,再注意下
    m_pSubThread自动析构问题。
      

  4.   

    我已经用PostMessage的方式搞定了,重写一下WindowProc函数,谢谢大家!