GetTickCount ,example: long CCache::InternalFlush() { long lFlushFrom; long n; long lFlushCount; // if not flushing then simply return if (!m_FlushEnabled) { return -1; } // if flush time is 0 then simply return if (m_FlushDeltaTime == 0) { return -1; } // if not time for a flush then return if ((long)GetTickCount() - m_LastFlushAt < m_FlushDeltaTime) { return -1; } // check if flush required // retrn variable will contain index to flush from to end of index lFlushFrom = FlushRequired(); lFlushCount = 0; // if required then flush if (lFlushFrom != -1) { // raise event to signal user if (m_bEventsEnabled) this->Fire_CacheFlushing(); for (n = m_ElementCount - 1; n >= lFlushFrom; n--) { lFlushCount++; EraseElement(m_pIndex_Time[n]); } // store time flushed m_LastFlushAt = GetTickCount(); // raise event to signal user if (m_bEventsEnabled) this->Fire_CacheFlushed(); } return lFlushCount; }
SetTimer()
再从OnTimer()中响应,有什么特殊吗?
long CCache::InternalFlush()
{
long lFlushFrom;
long n;
long lFlushCount; // if not flushing then simply return
if (!m_FlushEnabled)
{
return -1;
} // if flush time is 0 then simply return
if (m_FlushDeltaTime == 0)
{
return -1;
} // if not time for a flush then return
if ((long)GetTickCount() - m_LastFlushAt < m_FlushDeltaTime)
{
return -1;
} // check if flush required
// retrn variable will contain index to flush from to end of index
lFlushFrom = FlushRequired();
lFlushCount = 0; // if required then flush
if (lFlushFrom != -1)
{
// raise event to signal user
if (m_bEventsEnabled)
this->Fire_CacheFlushing(); for (n = m_ElementCount - 1; n >= lFlushFrom; n--)
{
lFlushCount++;
EraseElement(m_pIndex_Time[n]);
} // store time flushed
m_LastFlushAt = GetTickCount(); // raise event to signal user
if (m_bEventsEnabled)
this->Fire_CacheFlushed();
} return lFlushCount;
}
然后再使用时在事件中填写处理代码不就可以了