public static void SetGridTimer() { var timer = TimerUtils.CreateTimer(() => GridActions.InvokeFormIfRequired(), 2000, 2000); var taskTimer = TimerUtils.AddTimer(timer, "Grid", "Grid Updater", 2000, 2000); }
public static void StartTaskThenDisposeTimer(Timer timer, Task task) { if (!TaskUtils.IsNull(task)) { TaskStarter.StartTaskAccordingly(task); } TimerUtils.DisposeTimer(timer); }
public static void UpdateStatusConsecutively(Task task) { Timer timer = null; timer = TimerUtils.CreateTimer(() => TaskActions.UpdateStatusForConsecutiveTask(timer, task), 3000, 3000); var taskTimer = TimerUtils.AddTimer(timer, task.Name, "Consecutive Checker Timer", 3000, 3000); }
public static void UpdateStatusForLoaded(Task task) { Timer timer = null; timer = TimerUtils.CreateTimer(() => TaskActions.UpdateForLoadedTask(timer, task), 3000, 3000); var taskTimer = TimerUtils.AddTimer(timer, task.Name, "Loaded Task Updater", 3000, 3000); }
public static void UpdateStatusEverySeconds(Task task) { Timer timer = null; timer = TimerUtils.CreateTimer(() => TaskActions.UpdateTasksRunningStatus(timer, task), 3000, 3000); TimerUtils.AddTimer(timer, task.Name, "Task Status Updater", 3000, 3000); }
public static void UpdateForLoadedTask(Timer timer, Task task) { if (TaskUtils.IsNull(task)) { TimerUtils.DisposeTimer(timer); return; } TaskUpdater.UpdateTask(task); }
public static void UpdateTasksRunningStatus(Timer timer, Task task) { if (TaskUtils.IsNull(task)) { TimerUtils.DisposeTimer(timer); return; } TaskUpdater.UpdateTask(task); }
public static void RunTaskDisposeIfNull(Timer timer, Task task) { if (TaskUtils.IsNull(task)) { TimerUtils.DisposeTimer(timer); return; } TaskRunner.RunTask(task); }
public static void SetTaskStartingTimer(Task task) { var dueTime = TimeSpanUtils.GetMillisecondsFromNow(task.Period.StartDate); Timer timer = null; timer = TimerUtils.CreateTimer(() => TaskActions.StartTaskThenDisposeTimer(timer, task), dueTime, Timeout.Infinite); var taskTimer = TimerUtils.AddTimer(timer, task.Name, "Task Starting Timer", dueTime, -1); }
public static void UpdateStatusForConsecutiveTask(Timer timer, Task task) { if (TaskUtils.IsNull(task)) { TimerUtils.DisposeTimer(timer); return; } if (!TaskRunner.IsTaskRunning(task)) { TaskUtils.StartDelayForConsecutive(task); TimerUtils.DisposeTimer(timer); } }
public static void RunTaskPeriodically(Task task) { var dueTime = TimeSpan.Zero; var period = task.Period.TimeBetween; System.Threading.Timer timer = null; timer = TimerUtils.CreateTimer(() => TaskActions.RunTaskDisposeIfNull(timer, task), dueTime, period); var taskTimer = TimerUtils.AddTimer(timer, task.Name, "Periodical Runner Timer", dueTime, period); logger.Info($"{taskTimer} is added."); }
public static void StartDelayForConsecutive(Task task) { var startConsecutivelyValue = (float)form.StartConsecutivelyDelay.Value; var delay = (long) TimeSpanUtils .GenerateTimeSpan(startConsecutivelyValue, IntervalUtils.GetInterval()) .TotalMilliseconds; Timer timer = null; TimerUtils.CreateTimer(() => TaskActions.RunTaskUpdateTaskDisposeTimer(timer, task), delay, Timeout.Infinite); var taskTimer = TimerUtils.AddTimer(timer, task.Name, "Consecutive Delayer Timer", delay, -1); }
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 StartNotificationTimer(Task task) { if (task.EmailInfo == null) { return; } var taskStartingDate = task.Period.StartDate; var dontRunLongerThanValue = MainForm.Form.GetDontRunLongerThanValue(); bool tryToSend = false; System.Threading.Timer timer = null; timer = new System.Threading.Timer((e) => { if (TaskUtils.IsNull(task)) { TimerUtils.DisposeTimer(timer); return; } if (TimeSpanUtils .GetDifference(DateTime.Now, taskStartingDate) > dontRunLongerThanValue) { if (!tryToSend && TaskRunner.IsTaskRunning(task)) { tryToSend = true; EmailUtils.RedirectToSendEmail(task.Name, dontRunLongerThanValue); } TimerUtils.DisposeTimer(timer); } }, null, 0, 3000); var taskTimer = TimerUtils.AddTimer(timer, task.Name, "Notification Timer", 0, 3000); logger.Info($"{taskTimer} is added."); }
public static void RunTaskUpdateForConsecutiveDisposeTimer(Timer timer, Task task) { TaskRunner.RunTask(task); TaskUpdater.UpdateStatusConsecutively(task); TimerUtils.DisposeTimer(timer); }