示例#1
0
 public static void TryGracefulRelaunch()
 {
     try
     {
         Frame rootFrame = Window.Current.Content as Frame;
         if (rootFrame != null)
         {
             if (GnarlyClient.Instance.Connected)
             {
                 rootFrame.Navigate(typeof(MainPage));
             }
             else
             {
                 if (TryConnect())
                 {
                     rootFrame.Navigate(typeof(MainPage));
                 }
                 else
                 {
                     rootFrame.Navigate(typeof(LoginSelection));
                 }
             }
         }
     }
     catch (Exception exception)
     {
         ExceptionUploader.UploadException(exception.Message, exception.StackTrace);
         CoreApplication.Exit();
     }
 }
示例#2
0
 private async void App_EnteredBackground(object sender, EnteredBackgroundEventArgs e)
 {
     try
     {
         //GNARLY_TODO: Save the visual state.
         var frame      = Window.Current.Content as Frame;
         var mainWindow = frame.Content as MainPage;
         if (mainWindow != null && mainWindow.ActiveChannel != null)
         {
             _cachedMessages = await mainWindow.ActiveChannel.DownloadMessages(MainPage.MaxMessageDownloadCount);
         }
         _appPreviouslyRunning = true;
         GnarlyClient.Instance.Disconnect();
     }
     catch (TaskCanceledException)
     {
         CoreApplication.Exit();
     }
     catch (OperationCanceledException)
     {
         CoreApplication.Exit();
     }
     catch (HttpRequestException)
     {
         CoreApplication.Exit();
     }
     catch (Exception exception)
     {
         ExceptionUploader.UploadException(exception.Message, exception.StackTrace);
     }
     // RegisterTask(BackgroundClientTask, BackgroundClientTaskEntryPoint);
 }
示例#3
0
        public static void LogUnhandledError(Exception e)
        {
            ExceptionUploader.UploadException(e.Message, e.StackTrace);

            Frame rootFrame = Window.Current.Content as Frame;

            if (rootFrame != null)
            {
                rootFrame.Navigate(typeof(CatastrophicError));
            }
            else // window not activated yet so exit out.
            {
                CoreApplication.Exit();
            }
        }
示例#4
0
        private void App_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            try
            {
                Frame rootFrame = Window.Current.Content as Frame;
                if (rootFrame != null)
                {
                    if (GnarlyClient.Instance.Connected)
                    {
                        rootFrame.Navigate(typeof(MainPage));
                    }
                    else
                    {
                        if (TryConnect())
                        {
                            rootFrame.Navigate(typeof(MainPage));
                        }
                        else
                        {
                            rootFrame.Navigate(typeof(LoginSelection));
                        }
                    }
                }
                else
                {
                    throw new NullReferenceException("The current window content is invalid when attempting crash recovery.");
                }

                e.Handled = true;
            }
            catch (Exception exception)
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine("Global Unhandled Exception triggered");
                sb.AppendLine(exception.StackTrace);
                ExceptionUploader.UploadException(exception.Message, sb.ToString());
                CoreApplication.Exit();
            }
        }