private void LookingForGuest() { while (bar.guest.Count == 0) { Thread.Sleep(50); if (bar.mainWindow.token.IsCancellationRequested) { BartenderGoHome(); break; } } /* if (bar.guest.TryPeek(out Patron currentPatron)) * { * this.patron = currentPatron; * Thread.Sleep(bar.TimeToGetGlass); * bar.Log("Taking a glass".ma) * }*/ if (bar.guest.TryDequeue(out Patron dequeuedPatron)) { this.patron = dequeuedPatron; Thread.Sleep(bar.TimeToGetGlass); bar.Log("Walking to shelf", MainWindow.LogBox.Bartender); } }
private void WaitToPickGlasses() { while (!bar.table.IsEmpty) { if (bar.table.TryPop(out BeerGlass currentGlass)) { bar.glasses.Push(currentGlass); } } if (bar.glasses.Count > 0) { bar.Log("Picking up glass from table", MainWindow.LogBox.Waitress); Thread.Sleep(bar.TimeToPickGlasses); DoDishes(); } }
public Waitress(Bar bar) { this.bar = bar; Task.Run(() => { while ((bar.patronList.Count + bar.guest.Count) > 0 || bar.IsOpen) { WaitToPickGlasses(); } bar.Log("Waitress goes home", MainWindow.LogBox.Waitress); bar.WaitressIsPresent = false; }); }
public Bartender(Bar bar) { this.bar = bar; Task.Run(() => { while ((bar.patronList.Count + bar.guest.Count) > 0 || bar.IsOpen) { bar.Log("Waiting for guest to arraive", MainWindow.LogBox.Bartender); LookingForGuest(); WhenGuestOrders(); } BartenderGoHome(); }); }
public Bouncer(Bar bar) { this.bar = bar; Task.Run(() => { while (bar.IsOpen) { if (bar.Busload) { BusloadTime(); } if (bar.CouplesNight) { CouplesNightTime(); } else { int sleepTime; if (bar.Busload) { sleepTime = bar.TimeToCheckID; } else { sleepTime = bar.TimeToCheckID / 2; } Thread.Sleep(sleepTime); if (bar.mainWindow.token.IsCancellationRequested) { return; } bar.guest.Enqueue(new Patron(bar)); Thread.Sleep(sleepTime); } } bar.Log("Bouncer goes home", MainWindow.LogBox.Patron); }); }
private void EnterBar() { bar.Log($"{Name} enters the bar", MainWindow.LogBox.Patron); Thread.Sleep(bar.TimeToWalkToBar); bar.Log($"{Name} arrives at the bar", MainWindow.LogBox.Patron); }