示例#1
0
        /// <summary>
        /// Adds an interval reservation on a specific time object.
        /// </summary>
        /// <returns>A token to enable, disable or remove the interval reservation at a later time.</returns>
        /// <param name="listener">A Listener which will be triggered on each iteration.</param>
        /// <param name="timeToken">The timeToken obtained from GetTimeToken.</param>
        public object AddInterval(TimeReached listener, object timeToken)
        {
            var reservation = new IntervalReservation()
            {
                Enabled   = true,
                Listener  = listener,
                TimeToken = timeToken
            };

            lock (intervalReservations)
            {
                intervalReservations.Add(reservation);
            }
            return(reservation);
        }
示例#2
0
        /// <summary>
        /// Adds an alarm reservation on a specific time object.
        /// </summary>
        /// <returns>An alarm token. Use this token to cancel the alarm at a later time.</returns>
        /// <param name="listener">Listener.</param>
        /// <param name="time">Time.</param>
        /// <param name="timeToken">Time token.</param>
        public object AddAlarm(TimeReached listener, Time time, object timeToken)
        {
            // Create a copy of the time object so it can not be changed externaly.
            Time timeCopy = time.MakeCopy();

            var reservation = new AlarmReservation()
            {
                AlarmTime = timeCopy,
                Enabled   = true,
                Listener  = listener,
                TimeToken = timeToken
            };

            lock (alarmReservations)
            {
                alarmReservations.Add(reservation);
            }

            return(reservation);
        }
示例#3
0
 /// <summary>
 /// Standard Event/Delegate handler, if its not null, fire the event
 /// </summary>
 private void OnTimeReached()
 {
     // Fire the event
     TimeReached?.Invoke(GetMidnight(s_MinutesAfterMidnight));
 }