SuspendThread() problem
Hi, hopefully this issue is a little more solveable than some of my
other questions.
I have a multithreaded application (wasn't originally, I'm porting it
to multithreaded to release the GUI). In the worker thread, I
eventually run into some code that looks like this:
iRet = funct(iRet);
switch (iRet)
{
case 0x1F:
case 0x20:
case 0x11:
case 11:
SuspendThread();
And my program is crashing inside Suspend Thread. So I checked out
the assert it was tanking on and got this:
_AFXWIN_INLINE DWORD CWinThread::SuspendThread()
{ ASSERT(m_hThread != NULL); return ::SuspendThread(m_hThread); }
Huh? How can m_hThread be NULL on a working thread?! I know it's
working because I set up a test case where this gets triggered on the
last action, after ~10-12 seconds. It's correctly signaling to update
the GUI window, and I can see that my algorithm is executing. So how
can an existing thread that has been operating fail to suspend itself?
It has me stumped...
Here's my call to create the thread:
//Inside GUI code.
m_pChildThread = AfxBeginThread(THREADStartEngine, m_pEngine);
UINT THREADStartEngine(LPVOID pParam)
{
CPrgStackEngine *pEngine = (CPrgStackEngine *) pParam;
if (pEngine == NULL)
return 1;
pEngine->PrepareEngine();
return 0;
}
Where PrepareEngine does all the work.
Anybody have any guesses on what I'm seeing here?