Example #1
0
        private void execute(Job job)
        {
            try
            {
                System.Threading.Thread.Sleep(job.Delay);
                job.Handler(this);
            }
            catch
            {
                //TODO: log...
            }

            switch (job.Type)
            {
                case JobType.Once:
                case JobType.TimeSpecific:
                    Jobs.RemoveAt(index);
                    break;
                default:
                    job.LastExecution = DateTime.Now;
                    break;
            }
        }
Example #2
0
        private void cmdStart()
        {
            scheduler.Interval = 100;

            for (int i = 0; i < lbTasks.Items.Count; i++)
            {
                DBIntegrationTask task = lbTasks.Items[i] as DBIntegrationTask;

                Job job = new Job
                              {
                                  Interval = task.ExecInterval * 1000,
                                  Type = JobType.PeriodicMS,
                                  Handler = schedulerEngine => executeTask(task)
                              };
                scheduler.Jobs.Add(job);
            }

            scheduler.Start();

            btnStart.Enabled =
                btnAddNewTask.Enabled =
                btnDeleteSelectedTask.Enabled =
                btnEditSelectedTask.Enabled =
                btnScriptInclude.Enabled =
                btnShowLog.Enabled =
                btnToggleSelectedTask.Enabled = false;

            btnStop.Enabled = true;
        }