static void Main(string[] args) { StaffLogForBonuses staffLogs = new StaffLogForBonuses(); ToDoQueue toDoQueue = new ToDoQueue(staffLogs); SalesPerson[] people = { new SalesPerson("Sahil"), new SalesPerson("Peter"), new SalesPerson("Juliette"), new SalesPerson("Xavier") }; StockController controller = new StockController(toDoQueue); TimeSpan workDay = new TimeSpan(0, 0, 1); Task t1 = Task.Run(() => new SalesPerson("Sahil").Work(controller, workDay)); Task t2 = Task.Run(() => new SalesPerson("Peter").Work(controller, workDay)); Task t3 = Task.Run(() => new SalesPerson("Juliette").Work(controller, workDay)); Task t4 = Task.Run(() => new SalesPerson("Xavier").Work(controller, workDay)); Task bonusLogger = Task.Run(() => toDoQueue.MonitorAndLogTrades()); Task bonusLogger2 = Task.Run(() => toDoQueue.MonitorAndLogTrades()); Task.WaitAll(t1, t2, t3, t4); toDoQueue.CompleteAdding(); Task.WaitAll(bonusLogger, bonusLogger2); controller.DisplayStatus(); staffLogs.DisplayReport(people); }
static void Main(string[] args) { var staffLogs = new StaffLogForBonuses(); var toDoQueue = new ToDoQueue(staffLogs); SalesPerson[] people = { new SalesPerson("Sahil"), new SalesPerson("Peter"), new SalesPerson("Juliette"), new SalesPerson("Xavier") }; var controller = new StockController(toDoQueue); var workDay = new TimeSpan(0, 0, 5); var t1 = Task.Run(() => people[0].Work(controller, workDay)); var t2 = Task.Run(() => people[1].Work(controller, workDay)); var t3 = Task.Run(() => people[2].Work(controller, workDay)); var t4 = Task.Run(() => people[3].Work(controller, workDay)); var bonusLogger = Task.Run(() => toDoQueue.MonitorAndLogTrades()); var bonusLogger2 = Task.Run(() => toDoQueue.MonitorAndLogTrades()); Task.WaitAll(t1, t2, t3, t4); toDoQueue.CompleteAdding(); Task.WaitAll(bonusLogger, bonusLogger2); controller.DisplayStatus(); staffLogs.DisplayReport(people); }
public ToDoQueue(StaffLogForBonuses staffResults) { _staffLogs = staffResults; }