I seen many post about having a timer on ANVIL. Here is a simple way of having a timer
in Anvil without having to worry about multi-threading.
You need to add an observable to <I>B_GetAdminObservable()</I>. On the <i>Process()</i>
handle monitor the M_HEARTBEAT message. Check some timer object for interval and
perform your operationat the specified time.
Here is some sample code.
<i>
void CObserver:

rocess(const Message* message, Observable* from, const Message* additionalInfo)
{
static CTimer _Timer(60000);
switch(message->GetType())
{
case M_HEARTBEAT:
{
// Timer Check
if ( _Timer.TimeToRun() )
{
// Do your thing here
}
}
break;
}
}
</i>
The Timer class here:
<i>
class CTimer
{
public:
CTimer(DWORD dIntervalMs, DWORD dLastTriggeredMs = 0)
{
m_IntervalMs = dIntervalMs;
m_LastTriggeredMs = dLastTriggeredMs;
}
bool TimeToRun()
{
if (

:GetTickCount() - m_LastTriggeredMs) > m_IntervalMs )
{
m_LastTriggeredMs = ::GetTickCount();
m_bDidItRun = true;
return true;
}
return false;
}
private:
DWORD m_IntervalMs;
DWORD m_LastTriggeredMs;
};
</i>