Exemplo n.º 1
0
        public void Start(TimeoutFunction timeoutfunction)
        {
            this._timeoutfunction = timeoutfunction;

            if (this.TimeoutElapsed != TimeSpan.MinValue)
            {
                if (this._resetonactivity)
                {
                    Director.Instance.ParentWindow.MouseDown += this.ResetElapsed;
                    Director.Instance.ParentWindow.KeyDown   += this.ResetElapsed;
                }
                this.AfterTimer.Interval = TimeoutElapsed;
                this.AfterTimer.Tick    += this.OnTimeoutReached;
                this._afterstarttime     = DateTime.Now;
                this._afterendtime       = this._afterstarttime + this.TimeoutElapsed;
                this.AfterTimer.Start();
                LoggerFacade.Info("Timeout will occur in " + this.TimeoutElapsed.TotalMilliseconds + " milliseconds");
            }

            if (this.TimeoutDateTime != DateTime.MaxValue)
            {
                //first check if the timeout datetime has already passed.
                if (this.TimeoutDateTime < DateTime.Now)
                {
                    Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.ContextIdle, new Action(() => this.OnTimeoutReached()));
                    return;
                }
                this.ResetAtTimerBlock(this, new EventArgs());
            }
        }
Exemplo n.º 2
0
        static DateTime CalculateReminder(Interval interval, string nextReminder, int?intervalStep)
        {
            var reminder = new ReminderDocument
            {
                NextReminder = DateTime.Parse(nextReminder),
                Reminder     = new Reminder()
                {
                    Interval     = interval,
                    IntervalStep = intervalStep
                }
            };

            TimeoutFunction.CalculateNextReminder(reminder, Now);

            return(reminder.NextReminder);
        }
Exemplo n.º 3
0
 public void RemoveTimeoutFunction(TimeoutFunction timeoutFunction)
 {
     //Potentially risky code- what happens if it's not there?
     timeoutFunctions.Remove(timeoutFunction);
 }
Exemplo n.º 4
0
 public void AddTimeoutFunction(TimeoutFunction timeoutFunction)
 {
     timeoutFunctions.Add(timeoutFunction);
 }