private void TaskRunPoller_OnException(object source, ServerPollerExceptionHandlerEventArgs e) { if (e.Exception.GetType() == typeof(FactoryOrchestratorUnkownGuidException)) { // Run no longer valid, mark as aborted taskRun.TaskStatus = TaskStatus.Aborted; _ = CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { ExitPage(); }); } else { // Call global error handler ((App)Application.Current).OnServerPollerException(source, e); } }
internal async void OnServerPollerException(object source, ServerPollerExceptionHandlerEventArgs e) { var poller = source as ServerPoller; if (e.Exception.GetType() == typeof(FactoryOrchestratorConnectionException)) { OnConnectionFailure(); } else if (poller.IsPolling) { pollingFailureSem.Wait(); try { if (e.Exception.GetType() == typeof(FactoryOrchestratorUnkownGuidException)) { // Service was likely restarted or the guid was deleted via another Client, stop polling it poller.StopPolling(); } await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async() => { var stopPollBox = new CheckBox() { IsChecked = false, Content = "Stop polling this object?" }; var dialogStack = new StackPanel { Orientation = Orientation.Vertical }; dialogStack.Children.Add(new TextBlock() { Text = e.Exception.Message + "\r\n\r\nThis can occur when the Factory Orchestrator Service is restarted during an operation", TextWrapping = TextWrapping.WrapWholeWords }); if (poller.IsPolling) { dialogStack.Children.Add(stopPollBox); } ContentDialog errorDialog = new ContentDialog() { Title = "Polling Exception", Content = dialogStack, CloseButtonText = $"Continue" }; try { await errorDialog.ShowAsync(); if (stopPollBox.IsChecked == true) { poller.StopPolling(); } } catch (Exception) { // TODO: Bug: i think this doesnt work ;) // System.Exception is thrown if there is already a ContentDialog visible on the screen. Just ignore it } }); } finally { pollingFailureSem.Release(); } } System.Diagnostics.Debug.WriteLine(e.Exception); }