private void LogTaskStarted(IWorkerTask task) { if (log.IsDebugEnabled && !ReferenceEquals(task, EndOfTaskMarker)) { log.Debug($"Task '{task.Id}' was chosen to run. {progress.DumpTasksStat()}"); } }
private void LogTaskFinished(IWorkerTask task, TimeSpan elapsed) { if (log.IsDebugEnabled && !ReferenceEquals(task, EndOfTaskMarker)) { log.Debug($"Task '{task.Id}' executed at {elapsed}. {progress.DumpTasksStat()}"); } }
private void ExecuteTask(IWorkerTask task) { var stopwatch = new Stopwatch(); stopwatch.Start(); progress.StartNewTask(); LogTaskStarted(task); try { if (isCanceled) { return; } task.Execute(); progress.EndTask(); } finally { stopwatch.Stop(); LogTaskFinished(task, stopwatch.Elapsed); } }
private void LogTaskWasEnqueue(IWorkerTask task) { if (log.IsDebugEnabled) { log.Debug($"Task '{task.Id}' was enqueue. {progress.DumpTasksStat()}"); } }
public static void QueueTask(IWorkerTask workerTask) { using (var repository = ContainerBootstrapper.Container.Resolve <IRepository <WorkerTask> >()) { var task = (WorkerTask)workerTask; task.Added = DateTime.Now; repository.Add(task); } ProcessQueue(); }
public void PushTask([NotNull] IWorkerTask task) { CheckDisposed(); if (task == null) { throw new ArgumentNullException(nameof(task)); } lock (syncObject) { taskQueue.Enqueue(task); progress.TaskQueueSize = taskQueue.Count; LogTaskWasEnqueue(task); Monitor.PulseAll(syncObject); } }
/// <summary> /// Initializes a new instance of the <see cref="WorkerTaskEventArgs"/> class. /// </summary> /// <param name="workerTask">The worker task that the event occurred on.</param> /// <param name="triggeredAt">The date/time the task was triggered at, not /// the event itself.</param> public WorkerTaskEventArgs(IWorkerTask workerTask, DateTime triggeredAt) { TriggeredAt = triggeredAt; Task = workerTask; }
protected WorkerAgent(IWorkerTask task) { Task = task; }