private void ScheduleExecutionCore(ScheduleCommandRequest request) { Trace.WriteLine(string.Format("Scheduling command {0} on {1}", request.Command.CommandText, request.Command.ClientName)); var task = new ActionTask(() => ExecuteCommandCore(request.Command)); switch (request.Trigger) { case Trigger.Single: task.AddTrigger(new ExactTimeTrigger(request.FirstDateTime)); break; case Trigger.Daily: task.AddTrigger(new DailyTrigger(request.FirstDateTime.TimeOfDay)); break; default: throw new ArgumentOutOfRangeException(); } _taskManager.AddTask(task); Trace.WriteLine("Command will be executed at {0}\r\n" + task.NextTime); }