예제 #1
0
        public async Task Listen()
        {
            while (true)
            {
                lock (Locker)
                {
                    if (IsCanceled)
                    {
                        return;
                    }
                }

                // Tick the Task Scheduler
                await TaskScheduler.Tick();

                // Execute Any Queued Tasks
                var(json, info) = await TaskQueue.SafeDequeue();

                if (info != null)
                {
                    LogTaskStarted(info);

                    try
                    {
                        var now = DateTime.Now;

                        await info.ExecuteTask();

                        var completionSeconds = (DateTime.Now - now).TotalSeconds;
                        LogTaskFinished(info, completionSeconds);
                    }
                    catch (Exception e)
                    {
                        LogTaskException(info, e);
                    }
                    finally
                    {
//                        TaskQueue.Backend.RemoveBackup(json);
                    }
                }

                // Restore any expired backup tasks
//                TaskQueue.RestoreExpiredBackupTasks();

                Thread.Sleep(PollDelay);
            }
        }
예제 #2
0
        public void Listen()
        {
            while (true)
            {
                if (IsCanceled)
                {
                    return;
                }

                // Tick the Task Scheduler
                TaskScheduler.Tick();

                // Execute Any Queued Tasks
                var(json, info) = TaskQueue.SafeDequeue();
                if (info != null)
                {
                    LogTask(info);

                    try
                    {
                        info.ExecuteTask();
                    }
                    catch (Exception e)
                    {
                        LogTaskException(info, e);
                    }
                    finally
                    {
                        TaskQueue.Backend.RemoveBackup(json);
                    }
                }

                // Restore any expired backup tasks
                TaskQueue.RestoreExpiredBackupTasks();

                Thread.Sleep(PollDelay);
            }
        }
예제 #3
0
        private async Task ExecuteQueuedTask()
        {
            var(json, info) = await TaskQueue.SafeDequeue();

            if (info != null)
            {
                LogTaskStarted(info);

                try
                {
                    var now = DateTime.Now;

                    await info.ExecuteTask();

                    var completionSeconds = (DateTime.Now - now).TotalSeconds;
                    LogTaskFinished(info, completionSeconds);
                }
                catch (Exception e)
                {
                    LogTaskException(info, e);
                }
            }
        }