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(); });
        }
示例#2
0
 public override void SmallCoffee()
 {
     Console.WriteLine("WorkingState: make small coffee");
     CoffeeMachine.TransistionTo(new WorkingState(5));
 }
示例#3
0
 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()));
        }