While continuing the series of MFC classes replication (for the knowledgeable) here comes the CEvent class replication:
class CEvent {
HANDLE m_hEvent;
public:
CEvent(
BOOL bInitialState,
BOOL bManualReset)
{
LPSECURITY_ATTRIBUTES lpEventAttributes = NULL;
m_hEvent = CreateEvent(lpEventAttributes,
bManualReset,
bInitialState,
NULL);
}
~CEvent()
{
m_hEvent = NULL;
}
BOOL SetEvent()
{
return ::SetEvent(m_hEvent);
}
BOOL ResetEvent()
{
return ::ResetEvent(m_hEvent);
}
HANDLE GetHandle()
{
return m_hEvent;
}
operator HANDLE()
{
return m_hEvent;
}
};
The code has been edited in consideration with the answer.
You are creating named event – _T(“Untitled”). Is this on purpose? This way each time CEvent will be created it will refer to the same event – no new one will be created.
Also think of destroying your event in destructor.