private void SaveCommands() { if (_historyStorage == null) { return; } try { string[] commands = null; lock (_commandsWriteLock) { commands = _commands.ToArray(); } lock (_historyStorage) { _historyStorage.Save(commands); } } catch { // ignore } }