|
////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2006 Werner Willemsens
//
////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "notifier.h"
CNotifier *g_TheNotifier;
CNotifier::CNotifier()
{
::InitializeCriticalSection(&m_Protect);
BeginThread();
}
CNotifier::~CNotifier()
{
::DeleteCriticalSection(&m_Protect);
}
int CNotifier::DoWork()
{
return Read();
}
int CNotifier::Read()
{
tMsg Msg;
::EnterCriticalSection(&m_Protect);
Msg = m_Msg;
::LeaveCriticalSection(&m_Protect);
// Call class member function
((Msg.m_Dummy)->*Msg.m_Func)(&Msg.m_vVARIANT);
return 0;
}
int CNotifier::Write(tMsg *Msg)
{
::EnterCriticalSection(&m_Protect);
m_Msg = *Msg;
::LeaveCriticalSection(&m_Protect);
long n;
BOOL bRet = ReleaseSemaphore(m_hEventTrigger, 1, &n);
return 0;
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.