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()); } }
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); }
public void RemoveTimeoutFunction(TimeoutFunction timeoutFunction) { //Potentially risky code- what happens if it's not there? timeoutFunctions.Remove(timeoutFunction); }
public void AddTimeoutFunction(TimeoutFunction timeoutFunction) { timeoutFunctions.Add(timeoutFunction); }