示例#1
0
    private void processListener(ISSTimerListener pListener)
    {
        OBJ_LISTEN_INFO pListenInfo = pListener.getListenerInfo();
        if (null == pListenInfo)
        {
            return;
        }

        // 没生效就返回
        if (!pListenInfo.bEnable)
        {
            return;
        }

        if (m_uTickCount < pListenInfo.msTimerEventTickCount)
        {
            return;
        }

        if (0 != (pListenInfo.nSetting & (int)eSSTimerSetting.eSSTimerOnlyOnce)) 
        {
            pListenInfo.bEnable = false;
            pListener.onTimeUp(m_uTickCount - pListenInfo.msTimerEventTickCount);
        }
        else if (0 != (pListenInfo.nSetting & (int)eSSTimerSetting.eSSTimerDontFillPastTime))
        {
            uint uDuration = m_uTickCount - pListenInfo.msTimerEventTickCount;
            if (pListener.onTimeUp(uDuration))
            {
                pListenInfo.msTimerEventTickCount += (pListenInfo.msInterval + (uDuration - uDuration % pListenInfo.msInterval));
            }
        }
        else
        {
            while (pListenInfo.msTimerEventTickCount <= m_uTickCount)
            {
                uint uOverTime = m_uTickCount - pListenInfo.msTimerEventTickCount;
                pListenInfo.msTimerEventTickCount += pListenInfo.msInterval;

                if (pListener.onTimeUp(uOverTime) == false)
                {
                    break;
                }
            }
        }
    }