Ejemplo n.º 1
0
    /// <summary>
    /// Checks if a timer is complete returns true if it is false if not
    /// if the timer is complete and restart is true the timer is restarted
    /// if the timer is complete and restart is false the timer is removed
    /// if no timer of the given id exists false is returned
    /// </summary>
    /// <param name="timerID">the id of the timer to check</param>
    /// <param name="restart">If the timer should be restarted</param>
    /// <returns>true if timer is done false if not</returns>
    private bool isTimerDone(string timerID, bool restart)
    {
        bool retObj = false;

        if (timers.ContainsKey(timerID))
        {
            WUTimer t = timers[timerID];
            if (t.done())
            {
                if (restart)
                {
                    t.Restart();
                }
                else
                {
                    timers.Remove(timerID);
                }
                retObj = true;
            }
            else
            {
                retObj = false;
            }
        }
        return(retObj);
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Create a new timer with the given id and wait time
    /// If a timer of the given id exists false is returned
    /// </summary>
    /// <param name="timerID"></param>
    /// <param name="waitTimeInMillisec">the time for the new timer to wait in millisec</param>
    /// <returns></returns>
    public bool Set(string timerID, int waitTimeInMillisec)
    {
        bool suc = false;

        if (!timers.Keys.Contains(timerID))
        {
            WUTimer newTimer = new WUTimer(waitTimeInMillisec);
            timers.Add(timerID, newTimer);
            suc = true;
        }
        return(suc);
    }
Ejemplo n.º 3
0
    /// <summary>
    /// Updates the wait time and resets the timer of the given id.
    /// If no timer is found returns false
    /// </summary>
    /// <param name="timerID">the id of the timer to update</param>
    /// <param name="newTimeInMillisec">the new time in millisec</param>
    /// <returns>true if successful false if not</returns>
    public bool Update(string timerID, int newTimeInMillisec)
    {
        bool suc = false;

        if (timers.Keys.Contains(timerID))
        {
            WUTimer toUpdate = timers[timerID];
            toUpdate.Update(newTimeInMillisec);
            suc = true;
        }
        return(suc);
    }