public async Task FinishTune() { await Task.Run(() => { try { TunedChannels.Clear(); _actualTuningDVBTType = -1; _actualTunningChannel = -1; State = TuneState.Ready; } catch (Exception ex) { _loggingService.Error(ex); } finally { OnPropertyChanged(nameof(TuningLabel)); OnPropertyChanged(nameof(AutomaticTuningProgress)); OnPropertyChanged(nameof(TuningFinished)); OnPropertyChanged(nameof(TunedChannels)); OnPropertyChanged(nameof(AddChannelsVisible)); } }); }
private async Task Tune() { _loggingService.Info($"Tuning"); State = TuneState.TuningInProgress; TunedChannels.Clear(); _channels = await _channelService.LoadChannels(); if (_channels == null) { _channels = new ObservableCollection <DVBTChannel>(); } OnPropertyChanged(nameof(TuningLabel)); OnPropertyChanged(nameof(AutomaticTuningProgress)); TuningAborted = false; try { if (ManualTuning) { long freq = Convert.ToInt64(TuneFrequency) * 1000000; long bandWidth = TuneBandwidth * 1000000; var ch = Convert.ToInt32((Convert.ToInt64(TuneFrequency) - 474 + 8 * 21) / 8); _actualTunningChannel = ch; _actualTuningDVBTType = 0; OnPropertyChanged(nameof(TuningLabel)); if (DVBTTuning) { await Tune(freq, bandWidth, 0); } _actualTuningDVBTType = 1; OnPropertyChanged(nameof(TuningLabel)); if (DVBT2Tuning) { await Tune(freq, bandWidth, 1); } } else { await AutomaticTune(); } State = TuneState.TuneFinishedOK; } catch (Exception ex) { State = TuneState.TuneFailed; } finally { OnPropertyChanged(nameof(TuningFinished)); OnPropertyChanged(nameof(TunedChannels)); OnPropertyChanged(nameof(AddChannelsVisible)); OnPropertyChanged(nameof(TuningLabel)); OnPropertyChanged(nameof(AutomaticTuningProgress)); } }