public static TimeLength random(TimeLength min, TimeLength max) { return(new TimeLength((long) (rnd.NextDouble() * (max.totalMinutes - min.totalMinutes) + min.totalMinutes))); }
public static TimeLength fromDays(long days) { return(TimeLength.fromHours(days * 24)); }
public static TimeLength operator -(Time ta, Time tb) { return(TimeLength.fromMinutes(ta.currentTime - tb.currentTime)); }
/// <summary> /// Registers a repeated-timer, which will be fired /// periodically for every specified interval. /// /// The first clock notification will be sent also after the /// specified minutes. /// </summary> /// <returns> /// The cookie, which shall be then used to unregister the timer. /// </returns> public ClockHandler registerRepeated(ClockHandler handler, TimeLength time) { return(registerRepeated(handler, time, time)); }
/// <summary> /// Registers an one-shot timer, which will be fired after /// the specified time span. /// </summary> public void registerOneShot(ClockHandler handler, TimeLength time) { Debug.Assert(time.totalMinutes > 0); queue.insert(currentTime + time.totalMinutes, handler); }
public RepeatedTimer(Clock _clock, ClockHandler _handler, TimeLength first, TimeLength _interval) { this.clock = _clock; this.handler = _handler; this.interval = _interval; clock.registerOneShot(new ClockHandler(onClock), first); }