public void SubmitTask() { int taskId = _rnd.Next(10000); string taskName = $"({taskId} for {Name})"; DeveloperTask newTask = new DeveloperTask(taskName); if (TaskExecutor != null) { TaskExecutor.AddTask(newTask); DeveloperTasks.Add(newTask); } }
public void CheckTaskStatus() { if (DeveloperTasks.Count > 0) { int taskIndex = _rnd.Next(0, DeveloperTasks.Count - 1); DeveloperTask checkTask = DeveloperTasks[taskIndex]; if (TaskExecutor != null && TaskExecutor.IsTaskDone(checkTask.Name)) { Console.WriteLine($"Task {checkTask.Name} is done for {Name}"); // remove it from the todo list DeveloperTasks.Remove(checkTask); } } }
public void AddTask(DeveloperTask newTask) { try { Lock.EnterWriteLock(); // if we already have this task (unique by name) // then just accept the add as sometimes people // give you the same task more than once :) var taskQuery = from t in DeveloperTasks where t == newTask select t; if (taskQuery.Count <DeveloperTask>() == 0) { Console.WriteLine($"Task {newTask.Name} was added to developer"); DeveloperTasks.Add(newTask); } } finally { Lock.ExitWriteLock(); } }