private void ApplyState(State state) { RemoveEvents(); if (_currentState != state) { //abort/dispose currently running job if (_currentState != null) _currentState.Dispose(); //update with new job _currentState = state; _currentState.DisplayContentChanged += _currentState_DisplayContentChanged; _currentState.StateChanged += _currentState_StateChanged; } AddEvents(); }
void _currentState_StateChanged(State newState) { ApplyState(newState); }
protected void RiseStateChangedEvent(State nextState) { StateChanged(nextState); }