myThread copy 2 - #include "myThread.h" # #include

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
#include ". .\myException\myException.h" # myThread::myThread(LPTHREAD_START_ROUTINE pThreadFunc, LPVOID pThreadFuncParameter,DWORD exeFlags, DWORD sSize,BOOL inheritable) { sa = (LPSECURITY_ATTRIBUTES)HeapAlloc(GetProcessHeap(),0,sizeof(SECURITY_ATTRIBUTES)); sa->nLength = sizeof(SECURITY_ATTRIBUTES); sa->lpSecurityDescriptor = NULL; sa->bInheritHandle = inheritable; s threadFunction = pThreadFunc; threadArgument = pThreadFuncParameter; t executeFlag = exeFlags; stackSize = sSize; exitCode = 0xFFFFFFFF; e } void myThread::execute() { if ( (thread = CreateThread(sa,stackSize,threadFunction,threadArgument,executeFlag,&threadId)) == NULL) { int errCode = 0; string header = "CreateThread() failed"; getErrorDetail(errCode,header); myException excp(errCode,header); throw excp; return; } } myThread::~myThread() { if (sa) { HeapFree(GetProcessHeap(),0,sa); sa = NULL; } } void myThread::waitForThreadToFinish() { if ( WaitForSingleObject(thread,INFINITE) == WAIT_FAILED ) { int errCode = 0; string header = "WaitForSingleObject() failed";
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 4

myThread copy 2 - #include "myThread.h" # #include

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online