.h
HANDLE handle;
static DWORD WINAPI Thread(xxxx* lpNotify);
.cpp
void xxxx:: startThread()
{
handle= CreateThread(NULL, 0, reinterpret_cast<LPTHREAD_START_ROUTINE>(Thread), lp, 0, NULL);
}
DWORD WINAPI xxxx::Thread( xxxx* lp )
{
while(WaitForSingleObject(lp->m_Stop, 0) == WAIT_TIMEOUT)
{
HANDLE _Signals[] =
{
pMainFrame->m_Stop,
pMainFrame->m_Event,
};
DWORD dwEvent = WaitForMultipleObjects(sizeof(_Signals) / sizeof(HANDLE), _Signals, FALSE, INFINITE);
bool isExit(false);
switch(dwEvent)
{
case WAIT_OBJECT_0:
isExit = true;
break;
case WAIT_FAILED:
isExit = true;
break;
case WAIT_OBJECT_0 + 1:
isExit = false;
break;
default:
isExit = true;
break;
}
if (isExit)
{
break;;
}
}
.h
static UINT Thread(LPVOID lpPara);
.cpp
void xxxx::startThread()
{
AfxBeginThread(Thread, this);
}
UINT xxxx::Thread(LPVOID lpPara)
{
return 0;
}