/// <summary> /// Called when the service is started. /// </summary> protected void OnStart(string[] args) { try { Thread serviceThread = new Thread(new ParameterizedThreadStart(StartAsync)); ManualResetEvent serviceStarting = new ManualResetEvent(false); serviceThread.Start(serviceStarting); serviceStarting.WaitOne(); serviceStarting.Close(); foreach (ScheduleBase schedule in ScheduleManager.GetSchedules()) { schedule.Settings.LastElapsed = new DateTime(0); ObjectHelper wrapper = new ObjectHelper(schedule); if (wrapper.HasProperty("TimeOfDay")) { wrapper.SetValue("TimeOfDay", DateTime.Now.TimeOfDay); } if (wrapper.HasProperty("DayOfMonth")) { wrapper.SetValue("DayOfMonth", DayOfMonth.AllDays); } } } catch (ThreadAbortException) { // do nothing. } }