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

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

View Full Document Right Arrow Icon
#include "myEvent.h" #include ". .\myException\myException.h" # myEvent::myEvent(string eventName,PAPCFUNC _pfnAPC,BOOL _queueUserAPC) { // set up the security features sa= (LPSECURITY_ATTRIBUTES) HeapAlloc(GetProcessHeap(),0,sizeof(SECURITY_ATTRIBUTES)); sa->nLength= sizeof(SECURITY_ATTRIBUTES); sa->lpSecurityDescriptor= NULL; sa->bInheritHandle= TRUE; // create the event, it is manual reset, initial state is nonsignaled / if ((event= CreateEvent(sa,TRUE,FALSE,eventName.c_str())) == NULL) { int errCode = 0; string header = "CreateEvent() in myEvent::myEvent() failed"; getErrorDetail(errCode,header); myException excp(errCode,header); throw excp; } // if a callback is provided, create a thread to monitor // the event. When the event occurs, queue the callback // as an APC (if the user wants to do so) / if ((pfnAPC=_pfnAPC) != NULL) { queueUserAPC = _queueUserAPC; { int errCode = 0; string header = "CreateThread() in myEvent::myEvent() failed"; getErrorDetail(errCode,header); myException excp(errCode,header); throw excp; } } else thread= NULL; } myEvent::~myEvent() { cout << "I am in myEvent destructor. .." << endl; c HeapFree(GetProcessHeap(),0,sa); if (thread) CloseHandle(thread);
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.

This note was uploaded on 03/27/2011 for the course COMPUTER 101 taught by Professor Bobthebuilder during the Spring '11 term at Columbia College.

Page1 / 4

myEvent copy 2 - #include &quot;myEvent.h&quot; # #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