#include ".\thread.h" HANDLE Thread::start() { unsigned threadId=0; _hThread = (HANDLE)_beginthreadex( NULL, // no security attributes (child cannot inherited handle) 1024*1024, // 1MB stack size threadFunc, // code to run on new thread this, // pointer to host application class 0, // run immediately (could create suspended) &threadId // OUT: returns thread ID ); return _hThread; } void Thread::waitForTermination() { // wait for it to stop WaitForSingleObject(_hThread, INFINITE); // close thread handle CloseHandle(_hThread); _hThread=0; }