关于创建的线程执行完就崩溃的问题

yimao_44 yimao_44 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我的程序有个要求,就是当按下某个按钮之后启动新进程,在新进程中安排一些操作等
的新进程弄好的 但是执行完毕的时候总是自己死在了一个系统函数


inline void* CThreadSlotData::GetThreadValue(int nSlot)
{
EnterCriticalSection(&m_sect);
ASSERT(nSlot != 0 && nSlot < m_nMax);
ASSERT(m_pSlotData != NULL);
ASSERT(m_pSlotData[nSlot].dwFlags & SLOT_USED);
ASSERT(m_tlsIndex != (DWORD)-1);
if( nSlot <= 0 || nSlot >= m_nMax ) // check for retail builds.
{
LeaveCriticalSection(&m_sect);
return NULL;
}

CThreadData* pData = (CThreadData*)TlsGetValue(m_tlsIndex);
if (pData == NULL || nSlot >= pData->nCount)
{
LeaveCriticalSection(&m_sect);
return NULL;
}
void* pRetVal = pData->pData[nSlot];
LeaveCriticalSection(&m_sect);
return pRetVal;
}



死在上面的 void* pRetVal = pData->pData[nSlot];
LeaveCriticalSection(&m_sect); 这块了

我的创建代码如下


void CBuildImageLibDlg::OnBnClickedButtonRecog()
{
// TODO: Add your control notification handler code here
m_pThrd = AfxBeginThread(RecogFunc,this,NULL,0,0,NULL);
if( m_pThrd!= NULL)
{
m_ThreadHandle = m_pThrd->m_hThread;
CloseHandle(m_ThreadHandle);
}

}


...全文

相关推荐

评论 9
收藏 已收藏
分享
返回顶部
yimao_44
进程/线程/DLL 15,466 成员 49,169 内容