Beispiel #1
0
 public void pause(ISSTimerListener pListener)
 {
     OBJ_LISTEN_INFO pListenInfo = pListener.getListenerInfo();
     if (null != pListenInfo)
     {
         pListenInfo.bEnable = true;
     }
 }
Beispiel #2
0
    public void resume(ISSTimerListener pListener)
    {
        OBJ_LISTEN_INFO pListenInfo = pListener.getListenerInfo();
        if (null != pListenInfo) {

            pListenInfo.msTimerEventTickCount = getTimerCount() + pListenInfo.msInterval;
            pListenInfo.bEnable = true;
        }
    }
Beispiel #3
0
    public bool RegListener(ISSTimerListener pListener, uint uInterval, int eSetting)
    {
        if (!m_lstListeners.Contains(pListener))
        {
            m_lstListeners.Add(pListener);
        }

        OBJ_LISTEN_INFO pListenInfo = pListener.getListenerInfo();
        if (null != pListenInfo)
        {
            pListenInfo.nSetting = (int)(eSetting);
            pListenInfo.msInterval = uInterval;
            pListenInfo.msTimerEventTickCount = getTimerCount() + uInterval;
            pListenInfo.bEnable = (0 != (eSetting & (int)eSSTimerSetting.eSSTimerPaused));
        }
        return true;
    }
Beispiel #4
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;
                }
            }
        }
    }