public WorkingState(int time) { _cancellationTokenSource = new CancellationTokenSource(); var task = Task.Delay(TimeSpan.FromSeconds(time), _cancellationTokenSource.Token); task.ContinueWith(x => { CoffeeMachine.TransistionTo(new IdleState()); _cancellationTokenSource.Dispose(); }); }
public override void SmallCoffee() { Console.WriteLine("WorkingState: make small coffee"); CoffeeMachine.TransistionTo(new WorkingState(5)); }
public override void LargeCoffee() { Console.WriteLine("WorkingState: make large coffee"); CoffeeMachine.TransistionTo(new WorkingState(10)); }
public HeatingUpState() { var task = Task.Delay(TimeSpan.FromSeconds(5)); task.ContinueWith(x => CoffeeMachine.TransistionTo(new IdleState())); }