protected void Application_Start(Object sender, EventArgs e) { int nowhour = Convert.ToInt32(DateTime.Now.Hour.ToString()); int nowmin = Convert.ToInt32(DateTime.Now.Minute.ToString()); SchedulerConfiguration config = new SchedulerConfiguration(1000000 * 3); //config.Jobs.Add(new SampleJob()); //Scheduler scheduler = new Scheduler(config); //System.Threading.ThreadStart myThreadStart = new System.Threading.ThreadStart(scheduler.Start); //System.Threading.Thread schedulerThread = new System.Threading.Thread(myThreadStart); /*config.Jobs.Add(new GraspJob()); * Scheduler scheduler = new Scheduler(config); * System.Threading.ThreadStart myThreadStart = new System.Threading.ThreadStart(scheduler.Start); * System.Threading.Thread schedulerThread = new System.Threading.Thread(myThreadStart); * //if ((nowhour >= 13 && nowmin >= 48) && (nowhour >= 13 && nowmin < 50)) * //{ * schedulerThread.Start(); * //} * /*schedulerThread.Start(); * System.Timers.Timer tr1 = new System.Timers.Timer(8000); * tr1.AutoReset = true; * tr1.Enabled = true; * tr1.Start(); * tr1.Elapsed += new System.Timers.ElapsedEventHandler(tr1_Elapsed); */ }
void tr1_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { int nowhour = Convert.ToInt32(DateTime.Now.Hour.ToString()); int nowmin = Convert.ToInt32(DateTime.Now.Minute.ToString()); SchedulerConfiguration config = new SchedulerConfiguration(1000 * 3); config.Jobs.Add(new SampleJob()); Scheduler scheduler = new Scheduler(config); System.Threading.ThreadStart myThreadStart = new System.Threading.ThreadStart(scheduler.Start); System.Threading.Thread schedulerThread = new System.Threading.Thread(myThreadStart); if ((nowhour >= 10 && nowmin >= 28) && (nowhour >= 11 && nowmin < 29)) { schedulerThread.Start(); } else { schedulerThread.Abort(); while (schedulerThread.ThreadState != ThreadState.Aborted) { Thread.Sleep(100); } } }
public Scheduler(SchedulerConfiguration config) { configuration = config; }