예제 #1
0
        public static void StartTaskThenDisposeTimer(Timer timer, Task task)
        {
            if (!TaskUtils.IsNull(task))
            {
                TaskStarter.StartTaskAccordingly(task);
            }

            TimerUtils.DisposeTimer(timer);
        }
예제 #2
0
        public static void UpdateForLoadedTask(Timer timer, Task task)
        {
            if (TaskUtils.IsNull(task))
            {
                TimerUtils.DisposeTimer(timer);
                return;
            }

            TaskUpdater.UpdateTask(task);
        }
예제 #3
0
        public static void UpdateTasksRunningStatus(Timer timer, Task task)
        {
            if (TaskUtils.IsNull(task))
            {
                TimerUtils.DisposeTimer(timer);
                return;
            }

            TaskUpdater.UpdateTask(task);
        }
예제 #4
0
        public static void RunTaskDisposeIfNull(Timer timer, Task task)
        {
            if (TaskUtils.IsNull(task))
            {
                TimerUtils.DisposeTimer(timer);
                return;
            }

            TaskRunner.RunTask(task);
        }
예제 #5
0
        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);
            }
        }
예제 #6
0
        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.");
        }
예제 #7
0
 public static void RunTaskUpdateForConsecutiveDisposeTimer(Timer timer, Task task)
 {
     TaskRunner.RunTask(task);
     TaskUpdater.UpdateStatusConsecutively(task);
     TimerUtils.DisposeTimer(timer);
 }