public static void StartTaskThenDisposeTimer(Timer timer, Task task) { if (!TaskUtils.IsNull(task)) { TaskStarter.StartTaskAccordingly(task); } TimerUtils.DisposeTimer(timer); }
void TasksDataGrid_CellClick(object sender, DataGridViewCellEventArgs e) { // If click new row or header if (e.RowIndex == tasksDataGrid.NewRowIndex || e.RowIndex < 0) { return; } if (e.ColumnIndex == tasksDataGrid.Columns["dataGridViewDeleteButtonColumn"].Index) { if (MessageBox.Show("Are you sure you want to delete this task?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { var taskId = e.RowIndex; TimerUtils.DisposeTimers(taskId); Repository.DeleteTaskById(taskId); GridUtils.UpdateGrid(); } } else if (e.ColumnIndex == tasksDataGrid.Columns["dataGridViewStartButtonColumn"].Index) { var taskId = e.RowIndex; var task = Repository.GetTaskById(taskId); if (task == null) { MessageBox.Show("Internal error. Task could not be found."); return; } if (ProcessUtils.IsProcessRunning(task)) { MessageBox.Show("Task is already running."); return; } TimerUtils.DisposeTimers(task); TaskStarter.GridStarter(task); GridUtils.UpdateGrid(); } }
private static void CheckForStartConsecutively(Task task) { if (task == null) { return; } if (task.Period.Property == StartProperty.Consecutively) { if (form.StartConsecutivelyNowButton.Checked) { TaskStarter.StartTaskConsecutively(task); } else if (form.StartConsecutivelySelectDateButton.Checked) { TaskUtils.SetTaskStartingTimer(task); } } }
private static void CheckForStartOnce(Task task) { if (task == null) { return; } if (task.Period.Property == StartProperty.Once) { if (form.StartOnceNowButton.Checked) { TaskStarter.StartTaskOnce(task); } else if (form.StartOnceSelectDateButton.Checked) { TaskUtils.SetTaskStartingTimer(task); } } }