Ejemplo n.º 1
0
        public static void SetGridTimer()
        {
            var timer = TimerUtils.CreateTimer(() =>

                                               GridActions.InvokeFormIfRequired(), 2000, 2000);

            var taskTimer = TimerUtils.AddTimer(timer, "Grid", "Grid Updater", 2000, 2000);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        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.");
        }
Ejemplo n.º 7
0
        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);
        }
Ejemplo n.º 8
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.");
        }