Example #1
0
        private void AttachTimer()
        {
            var millisecondsToExectution = (long)RunTime().Subtract(DateTime.Now.TimeOfDay).TotalMilliseconds;

            if (millisecondsToExectution < 0)
            {
                if (Recurs == null)
                {
                    millisecondsToExectution = (24 * 60 * 60 * 1000) + millisecondsToExectution;
                }
                else
                {
                    millisecondsToExectution = (long)Recurs.Value.TotalMilliseconds + millisecondsToExectution;
                }
            }

            if (millisecondsToExectution == 0)
            {
                millisecondsToExectution = 1000;
            }

            lock (_callbackLock)
            {
                _timer = new TimerPlus { Interval = millisecondsToExectution, AutoReset = false };
                _timer.Elapsed += (sender, e) => ScheduleCallback(this, e);
            }
        }
Example #2
0
        public void Dispose()
        {
            if (_timer == null) return;

            _timer.Dispose();
            _timer = null;
        }