private void Activate()
 {
     _errorProvider.DoWith(() => _activateCallbacks.ForEach(action => action()), "Failed to activate activity timer");
 }
        private void HandleInput(object sender, string barcode)
        {
            if (IsLocked)
            {
                // ignore inputs when locked
                return;
            }

            _errorProvider.DoWith(() =>
            {
                Barcode code = new Barcode(barcode);

                switch (code.Type)
                {
                case Barcode.Types.User:
                    _currentUser = _connector.GetUser(code.BarCode);
                    if (_currentUser == null)
                    {
                        SwitchToState(States.Welcome);
                    }
                    else
                    {
                        SwitchToState(States.Shopping);
                    }
                    break;

                case Barcode.Types.Item:
                    if (_currentState.State == States.Shopping)
                    {
                        var response = _connector.OrderItem(_currentUser.Short, barcode);
                        _currentUser = response.User;
                        _currentItem = response.Item;
                        if (_currentItem != null && _currentUser != null)
                        {
                            SwitchToState(States.Finished);
                        }
                        else
                        {
                            throw new UnknownItemException(barcode);
                        }
                    }
                    else
                    {
                        _currentUser = null;
                        _currentItem = _connector.GetItem(barcode);
                        SwitchToState(_currentItem != null ? States.PriceInfo : States.Welcome);
                    }
                    break;

                case Barcode.Types.Command:
                    barcode = barcode.Trim().ToLowerInvariant();
                    switch (barcode)
                    {
                    case "update":
                        Application.Exit();
                        break;

                    case "stock":
                        SwitchToState(States.StockItems);
                        break;

                    default:
                        var errorProvider = new ErrorProvider();
                        errorProvider.SendMail("Unknown command scanned.", "An unknown command has been scanned. THe command was " + barcode);
                        break;
                    }
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }, "Handle input of barcode {0} failed", barcode);
        }