示例#1
0
 public static TimeLength random(TimeLength min, TimeLength max)
 {
     return(new TimeLength((long)
                           (rnd.NextDouble() * (max.totalMinutes - min.totalMinutes) + min.totalMinutes)));
 }
示例#2
0
 public static TimeLength fromDays(long days)
 {
     return(TimeLength.fromHours(days * 24));
 }
示例#3
0
 public static TimeLength operator -(Time ta, Time tb)
 {
     return(TimeLength.fromMinutes(ta.currentTime - tb.currentTime));
 }
示例#4
0
 /// <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));
 }
示例#5
0
 /// <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);
 }
示例#6
0
 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);
 }