2013년 7월 4일 목요일

create thread mfc

create thread in mfc


1. class member function thread

header

private: 
static DWORD TestThread(LPVOID lpParameter);

usage cpp

m_hTestThread = ::CreateThread(NULL,0, (LPTHREAD_START_ROUTINE) MpWatcherWnd::TestThread, (void*)(this), 0, &dwTestThread);

definition cpp


DWORD TestClass::TestThread(LPVOID lpParameter)
{
TestClass* pTest = (TestClass*)lpParameter;
if (pTest)
{
// work
}
else
{
// error!
}
return 0;
}


2. global thread


댓글 없음:

댓글 쓰기