1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| // Launch-Start thread
HANDLE classThread::launch(void)
{
if(this->status != THREAD_NOT_RUNNING) return this->handle;
// Create thread & return handle
this->handle = CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)_threadFn, (LPVOID)this, NULL, &this->_id);
return this->handle;
}
// Main thread function
UINT32 classThread::_threadFn(void * lParam)
{
classThread &thread = (classThread&)lParam;
// Change status
thread.status = THREAD_RUNNING;
// Execute main function
thread.mainFn();
// Clean up
CloseHandle(thread.handle);
thread.handle = NULL;
// Change status
thread.status = THREAD_NOT_RUNNING;
return 0;
} |
Partager