public Task SetScheduledTask(string name, string executable, string commandline, int hour, int minutes, DayOfWeek? dayOfWeek, int intervalInMinutes) { return Task.Factory.StartNew(() => { if (_scheduledTask == null ||_scheduledTask != null && _scheduledTask.Name == name) _scheduledTask = new ScheduledTask { CommandLine = commandline, Name = name, Executable = executable, Hour = hour, IntervalInMinutes = intervalInMinutes, Minutes = minutes, DayOfWeek = dayOfWeek }; }); }
private void LoadScheduledTask() { dynamic element = _root.ScheduledTask; if (element != null) { _scheduledTask = new ScheduledTask { Name = element.Attributes.Name, DayOfWeek = String.IsNullOrWhiteSpace(element.Attributes.DayOfWeek) ? null : Enum.Parse(typeof (DayOfWeek), element.Attributes.DayOfWeek), Hour = int.Parse( element.Attributes.Time), CommandLine = element.Attributes.CommandLine, Executable = element.Attributes.Executable }; } }
public Task RemoveScheduledTask(string name) { return Task.Factory.StartNew(() => { if (_scheduledTask != null && _scheduledTask.Name == name) _scheduledTask = null; }); }