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