private async Task RunAsync(ICheckoutQueue checkoutQueue) { while (true) { checkoutQueue.AddCustomer(new Customer()); await Task.Delay(1000); } }
private async Task RunAsync(ICheckoutQueue checkoutQueue) { while (true) { System.Console.WriteLine($"{checkoutQueue.NumOfWaitingCustomers} customers in line"); await Task.Delay(1000); } }
private async Task RunAsync(ICheckoutQueue checkoutQueue) { Random rand = new Random(); while (true) { if (checkoutQueue.GetNextCustomer()) { var checkoutProcessingTimeSeconds = rand.Next(1, 5); Console.WriteLine($"Checkout processing {checkoutProcessingTimeSeconds} seconds"); await Task.Delay(checkoutProcessingTimeSeconds * 1000); } else { await Task.Delay(1000); } } }
public CustomersAdder(ICheckoutQueue checkoutQueue) { Task.Factory.StartNew(() => RunAsync(checkoutQueue)); }
public CheckoutWaitMonitor(ICheckoutQueue checkoutQueue) { Task.Factory.StartNew(() => RunAsync(checkoutQueue)); }
public CheckoutStation(ICheckoutQueue checkoutQueue) { Task.Factory.StartNew(() => RunAsync(checkoutQueue)); }