/// <summary> /// Notifies the tracker of work beginning for a task /// </summary> /// <param name="taskName">Name of the task.</param> public static void work_begin(string taskName) { "TaskTracker".Log().Debug("Starting work for {0}".format_with(taskName)); TransactionLock.enter( TASK_TRACKER_NAME, () => { _activeTasksCount += 1; _activeTasks.Value.AddOrUpdate(taskName, 1, (key, oldValue) => oldValue + 1); }); }
/// <summary> /// Determines if there are active tasks running. /// </summary> /// <returns>A boolean value</returns> public static bool are_active_tasks() { bool activeTasksRunning = true; TransactionLock.enter(TASK_TRACKER_NAME, 1, () => { if (_activeTasksCount == 0) { activeTasksRunning = false; } }); return(activeTasksRunning); }
/// <summary> /// Gets the active tasks. /// </summary> /// <returns>The IEnumerable of active tasks.</returns> public static IEnumerable <string> get_active_tasks() { IList <string> activeTasks = new List <string>(); TransactionLock.enter( TASK_TRACKER_NAME, () => { foreach (var task in _activeTasks.Value) { activeTasks.Add(task.Key); } }); return(activeTasks); }
/// <summary> /// Notifies the tracker work has completed /// </summary> /// <param name="taskName">Name of the task.</param> public static void work_complete(string taskName) { "TaskTracker".Log().Debug("Completing work for {0}".format_with(taskName)); TransactionLock.enter( TASK_TRACKER_NAME, () => { _activeTasksCount -= 1; var taskCount = 0; _activeTasks.Value.TryRemove(taskName, out taskCount); if (taskCount != 0) { taskCount -= 1; _activeTasks.Value.AddOrUpdate(taskName, taskCount, (key, oldValue) => taskCount); } }); }