bool MyClass::StartMyTask()
{
if (!running_)
{
DWORD threadId;
HANDLE hThrd = ::CreateThread(NULL, 0, StartMyTaskThread, (LPVOID)this, 0, &threadId);
if (INVALID_HANDLE_VALUE == hThrd)
{
return false;
}
::CloseHandle(hThrd);
running_ = true;
}
return true;
}
DWORD WINAPI MyClass::StartMyTaskThread( LPVOID param )
{
MyClass* pThis = static_cast<MyClass*>(param);
...
pThis->pYourClass_ = new YourClass;
pThis->pYourClass_->StartYourTask(...);
...
return 0;
}