Example #1
0
        private void UpdateStartTimer()
        {
            m_startTimer?.Stop();
            m_startTimer?.Dispose();
            m_startTimer = null;

            if (IsSchedulingEnabled)
            {
                if (StartTime != null)
                {
                    TimeSpan delay = StartTime.Value.Subtract(DateTime.Now);

                    if (delay.TotalMilliseconds > 0)
                    {
                        m_startTimer = new System.Timers.Timer(delay.TotalMilliseconds)
                        {
                            AutoReset = false
                        };
                        m_startTimer.Elapsed += (s, e) =>
                        {
                            if (Enable.CanExecute(null))
                            {
                                Enable.Execute(null);
                            }
                        };
                        m_startTimer.Start();
                    }
                }
            }
        }