Пример #1
0
        private void wakeTimer_WakeTimerCompleted(object sender, DataEventArgs <DateTime> e)
        {
            var           wakeTimer     = (WakeTimer)sender;
            WakeScheduler wakeScheduler = null;

            if (!this.wakeTimers.TryGetValue(wakeTimer, out wakeScheduler))
            {
                return;
            }

            var tmp = WakeTimerCompleted;

            if (tmp != null)
            {
                tmp(this, new DataEventArgs <Tuple <WakeScheduler, DateTime> >(new Tuple <WakeScheduler, DateTime>(wakeScheduler, DateTime.Now)));
            }

            if (wakeScheduler != null)
            {
                var nextDueTime = wakeScheduler.NextDueTime;

                if (nextDueTime.HasValue)
                {
                    wakeTimer.SetTimer(nextDueTime.Value);
                }
            }
        }
Пример #2
0
        private void StartProgramsAfterScheduledWake(WakeScheduler wakeScheduler)
        {
            if (wakeScheduler == null)
            {
                return;
            }

            if (this.currentSettings != null && this.currentSettings.WakeSchedulers != null && this.currentSettings.EnableWakeTimers)
            {
                Task.Factory.StartNew(() =>
                {
                    System.Threading.Thread.Sleep(timeSpanBeforeStartProgramsAndServices);

                    try
                    {
                        if (wakeScheduler.StartProgramsAfterWake != null && wakeScheduler.StartProgramsAfterWake.Count > 0 && wakeScheduler.EnableStartProgramsAfterWake &&
                            (SystemWokenByWakeTimer() || wakeScheduler.StartProgramsWhenSystemIsAlreadyRunning))
                        {
                            WsapmLog.Log.WriteLine(Resources.Wsapm_Core.WsapmManager_StartProgramsAfterWake, LogMode.Normal);
                            ProgramManager.StartPrograms(wakeScheduler.StartProgramsAfterWake.ToArray());
                        }
                    }
                    catch (Exception ex)
                    {
                        WsapmLog.Log.WriteError(ex);
                    }
                });
            }
        }
Пример #3
0
        public bool Equals(WakeScheduler other)
        {
            if (other == null)
            {
                return(false);
            }

            return(this.GetHashCode() == other.GetHashCode());
        }
Пример #4
0
        public override bool Equals(object obj)
        {
            if (obj == null || GetType() != obj.GetType())
            {
                return(false);
            }

            WakeScheduler other = obj as WakeScheduler;

            return(this.Equals(other));
        }