public async void RefreshStatus() { RefreshStatusResult result = null; if (Proxies.IsInitialized) { try { result = new RefreshStatusResult() { ActiveRecordings = await Proxies.ControlService.GetActiveRecordings(), LiveStreams = await Proxies.ControlService.GetLiveStreams(), UpcomingRecording = await Proxies.ControlService.GetNextUpcomingRecording(false) }; } catch { result = null; } } if (result == null) { _activeRecordings = new ActiveRecording[0]; _liveStreams = new LiveStream[0]; _upcomingRecording = null; SetStatusIcon(ServerStatus.NotConnected); } else { _activeRecordings = result.ActiveRecordings; _liveStreams = result.LiveStreams; _upcomingRecording = result.UpcomingRecording; SetStatusIcon(GetServerStatus(result.ActiveRecordings, result.LiveStreams)); } }
private void _refreshStatusBackgroundWorker_DoWork(object sender, DoWorkEventArgs e) { if (this.IsConnected) { using (ControlServiceAgent tvControlAgent = new ControlServiceAgent()) { RefreshStatusResult result = new RefreshStatusResult(); result.ActiveRecordings = tvControlAgent.GetActiveRecordings(); result.LiveStreams = tvControlAgent.GetLiveStreams(); result.UpcomingRecording = tvControlAgent.GetNextUpcomingRecording(false); e.Result = result; } } }
private void _refreshStatusBackgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (e.Error != null || e.Cancelled || e.Result == null) { _activeRecordings = new ActiveRecording[0]; _liveStreams = new LiveStream[0]; _upcomingRecording = null; SetStatusIcon(ServerStatus.NotConnected); } else { RefreshStatusResult result = (RefreshStatusResult)e.Result; _activeRecordings = result.ActiveRecordings; _liveStreams = result.LiveStreams; _upcomingRecording = result.UpcomingRecording; SetStatusIcon(GetServerStatus(result.ActiveRecordings, result.LiveStreams)); } }