private ScannerSettings GetScannerSettings(int sourceIndex) { _logger.Debug("Searching scanner settings in cache..."); var searchSetting = _cacheSettings.Search(_scannerManager, sourceIndex); if (searchSetting != null) { _logger.Debug("Scanner settings was found"); return(searchSetting); } else { _logger.Debug("Scanner settings was not found"); } var needOfChangeSource = _sourceIndex.HasValue && _sourceIndex != _scannerManager.CurrentSourceIndex; if (needOfChangeSource) { new AsyncWorker <int>().RunWorkAsync(sourceIndex, _scannerManager.ChangeSource, ChangeSourceWaitTime); } if (_scannerManager.CurrentSource == null) { throw new Exception("Не удалось выбрать источник"); } if (sourceIndex == _scannerManager.CurrentSource.Index) { searchSetting = new AsyncWorker <IScannerManager, ScannerSettings>() .RunWorkAsync(_scannerManager, _cacheSettings.PushCurrentSource, PushSettingsWaitTime); } return(searchSetting); }