Ejemplo n.º 1
0
        private void LogTaskException(TaskInfo info, Exception exception)
        {
            OnError?.Invoke(exception);

            var logMessage = Messages.TaskThrewException(info);

            ThreadSafeColoredConsole.Exception(logMessage, exception);
        }
Ejemplo n.º 2
0
        public async Task Tick()
        {
            var tasks = _scheduledTasks.Values.ToList();

            foreach (var task in tasks)
            {
                try
                {
                    // Ensure only one worker processes the scheduled task at a time.
                    var backendLock = await _taskQueue.Backend.LockNonBlocking(task.LockKey);

                    if (backendLock == null)
                    {
                        continue;
                    }

                    try
                    {
                        var taskDidRun = await task.RunIfScheduleReached();

                        if (taskDidRun && !task.IsRecurring)
                        {
                            RemoveTaskFromSchedule(task);
                        }
                    }
                    finally
                    {
                        await backendLock.Release();
                    }
                }
                catch (Exception e)
                {
                    ThreadSafeColoredConsole.Exception("Error processing Schedule Tick.", e);
                }
            }
        }
Ejemplo n.º 3
0
        private void LogTaskFinished(TaskInfo info, double completionSeconds)
        {
            var logMessage = Messages.TaskFinished(info, completionSeconds);

            ThreadSafeColoredConsole.Info(logMessage);
        }
Ejemplo n.º 4
0
        private void LogTaskStarted(TaskInfo info)
        {
            var logMessage = Messages.TaskStarted(info);

            ThreadSafeColoredConsole.Info(logMessage);
        }