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

            pListenInfo.msTimerEventTickCount = getTimerCount() + pListenInfo.msInterval;
            pListenInfo.bEnable = true;
        }
    }
示例#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;
    }
示例#4
0
    public bool UnRegListener(ISSTimerListener pListener)
    {
        if (m_lstListeners.Contains(pListener))
        {
            m_lstListeners.Remove(pListener);
        }

        return true;
    }
示例#5
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;
                }
            }
        }
    }