THREAD_PRIORITY_NORMAL,
0,
CREATE_SUSPENDED);
CMsgProcThread是CWinThread的子类,CMsgProcThread类的头文件中有
DECLARE_DYNCREATE(CMsgProcThread)
CMsgProcThread的实现文件中有:
IMPLEMENT_DYNCREATE(CMsgProcThread, CWinThread)
这么会出这样的事呢?查了半天的资料没有找到为什么啊?
9 个解决方案
#1
你单步调试看看
#2
单调调度的时候发现在是AfxBeginThread()在调用CreatThread的下面第二个VERIFY出现的内存异常:
// start the thread just for MFC initialization
VERIFY(ResumeThread() != (DWORD)-1);
VERIFY(::WaitForSingleObject(startup.hEvent, INFINITE) == WAIT_OBJECT_0);
::CloseHandle(startup.hEvent);
// start the thread just for MFC initialization
VERIFY(ResumeThread() != (DWORD)-1);
VERIFY(::WaitForSingleObject(startup.hEvent, INFINITE) == WAIT_OBJECT_0);
::CloseHandle(startup.hEvent);
#3
你什么时候Resume的这个线程?
#4
//启动超时管理线程
m_pTimerMngrThread = AfxBeginThread(RUNTIME_CLASS(CTimerMngThread));
if (!m_pTimerMngrThread)
{
CA_TRC_ERR(DBGW_LOG_CTRL_APP_FRAME, "启动超时管理器失败!");
return FALSE;
}
m_pTimerMngrThread->m_bAutoDelete = FALSE;
//启动事件调度线程;
m_hEventDispatchThread = (HANDLE)_beginthreadex(NULL,0,DispatchEvent,(void *)(&m_CasDb[1]),0,NULL);
if (!m_hEventDispatchThread)
{
CA_TRC_ERR(DBGW_LOG_CTRL_APP_FRAME, "启动事件调度失败!");
return FALSE;
}
//启动消息处理线程
m_pMsgProcThread = AfxBeginThread(RUNTIME_CLASS(CMsgProcThread),
THREAD_PRIORITY_NORMAL,
0,
CREATE_SUSPENDED);
if (!m_pMsgProcThread)
{
CA_TRC_ERR(DBGW_LOG_CTRL_APP_FRAME, "启动消息处理器失败!");
return FALSE;
}
m_pMsgProcThread->m_bAutoDelete = FALSE;
CMsgProcThread::SetCasDb(m_pMsgProcThread,m_CasDb);
m_pMsgProcThread->ResumeThread();
m_pTimerMngrThread = AfxBeginThread(RUNTIME_CLASS(CTimerMngThread));
if (!m_pTimerMngrThread)
{
CA_TRC_ERR(DBGW_LOG_CTRL_APP_FRAME, "启动超时管理器失败!");
return FALSE;
}
m_pTimerMngrThread->m_bAutoDelete = FALSE;
//启动事件调度线程;
m_hEventDispatchThread = (HANDLE)_beginthreadex(NULL,0,DispatchEvent,(void *)(&m_CasDb[1]),0,NULL);
if (!m_hEventDispatchThread)
{
CA_TRC_ERR(DBGW_LOG_CTRL_APP_FRAME, "启动事件调度失败!");
return FALSE;
}
//启动消息处理线程
m_pMsgProcThread = AfxBeginThread(RUNTIME_CLASS(CMsgProcThread),
THREAD_PRIORITY_NORMAL,
0,
CREATE_SUSPENDED);
if (!m_pMsgProcThread)
{
CA_TRC_ERR(DBGW_LOG_CTRL_APP_FRAME, "启动消息处理器失败!");
return FALSE;
}
m_pMsgProcThread->m_bAutoDelete = FALSE;
CMsgProcThread::SetCasDb(m_pMsgProcThread,m_CasDb);
m_pMsgProcThread->ResumeThread();
#5
Try to use CreateThread
#6
干什么这么麻烦,给个EMAIL,给你个比较稳定的线程封装类。
#7
HANDLE hThread=CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)SearchFile,NULL,0,NULL);
CloseHandle(hThread);
UINT SearchFile(LPVOID lpParam)
{
return 0;
}
CloseHandle(hThread);
UINT SearchFile(LPVOID lpParam)
{
return 0;
}
#8
刚创建线程对象就出错,莫非你的CMsgProcThread类构造函数中有非法访问内存语句?
#9
MARK 一下
#1
你单步调试看看
#2
单调调度的时候发现在是AfxBeginThread()在调用CreatThread的下面第二个VERIFY出现的内存异常:
// start the thread just for MFC initialization
VERIFY(ResumeThread() != (DWORD)-1);
VERIFY(::WaitForSingleObject(startup.hEvent, INFINITE) == WAIT_OBJECT_0);
::CloseHandle(startup.hEvent);
// start the thread just for MFC initialization
VERIFY(ResumeThread() != (DWORD)-1);
VERIFY(::WaitForSingleObject(startup.hEvent, INFINITE) == WAIT_OBJECT_0);
::CloseHandle(startup.hEvent);
#3
你什么时候Resume的这个线程?
#4
//启动超时管理线程
m_pTimerMngrThread = AfxBeginThread(RUNTIME_CLASS(CTimerMngThread));
if (!m_pTimerMngrThread)
{
CA_TRC_ERR(DBGW_LOG_CTRL_APP_FRAME, "启动超时管理器失败!");
return FALSE;
}
m_pTimerMngrThread->m_bAutoDelete = FALSE;
//启动事件调度线程;
m_hEventDispatchThread = (HANDLE)_beginthreadex(NULL,0,DispatchEvent,(void *)(&m_CasDb[1]),0,NULL);
if (!m_hEventDispatchThread)
{
CA_TRC_ERR(DBGW_LOG_CTRL_APP_FRAME, "启动事件调度失败!");
return FALSE;
}
//启动消息处理线程
m_pMsgProcThread = AfxBeginThread(RUNTIME_CLASS(CMsgProcThread),
THREAD_PRIORITY_NORMAL,
0,
CREATE_SUSPENDED);
if (!m_pMsgProcThread)
{
CA_TRC_ERR(DBGW_LOG_CTRL_APP_FRAME, "启动消息处理器失败!");
return FALSE;
}
m_pMsgProcThread->m_bAutoDelete = FALSE;
CMsgProcThread::SetCasDb(m_pMsgProcThread,m_CasDb);
m_pMsgProcThread->ResumeThread();
m_pTimerMngrThread = AfxBeginThread(RUNTIME_CLASS(CTimerMngThread));
if (!m_pTimerMngrThread)
{
CA_TRC_ERR(DBGW_LOG_CTRL_APP_FRAME, "启动超时管理器失败!");
return FALSE;
}
m_pTimerMngrThread->m_bAutoDelete = FALSE;
//启动事件调度线程;
m_hEventDispatchThread = (HANDLE)_beginthreadex(NULL,0,DispatchEvent,(void *)(&m_CasDb[1]),0,NULL);
if (!m_hEventDispatchThread)
{
CA_TRC_ERR(DBGW_LOG_CTRL_APP_FRAME, "启动事件调度失败!");
return FALSE;
}
//启动消息处理线程
m_pMsgProcThread = AfxBeginThread(RUNTIME_CLASS(CMsgProcThread),
THREAD_PRIORITY_NORMAL,
0,
CREATE_SUSPENDED);
if (!m_pMsgProcThread)
{
CA_TRC_ERR(DBGW_LOG_CTRL_APP_FRAME, "启动消息处理器失败!");
return FALSE;
}
m_pMsgProcThread->m_bAutoDelete = FALSE;
CMsgProcThread::SetCasDb(m_pMsgProcThread,m_CasDb);
m_pMsgProcThread->ResumeThread();
#5
Try to use CreateThread
#6
干什么这么麻烦,给个EMAIL,给你个比较稳定的线程封装类。
#7
HANDLE hThread=CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)SearchFile,NULL,0,NULL);
CloseHandle(hThread);
UINT SearchFile(LPVOID lpParam)
{
return 0;
}
CloseHandle(hThread);
UINT SearchFile(LPVOID lpParam)
{
return 0;
}
#8
刚创建线程对象就出错,莫非你的CMsgProcThread类构造函数中有非法访问内存语句?
#9
MARK 一下