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); } }
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); } }
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); } } }