// Code to execute on Unhandled Exceptions private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e) { if (e.ExceptionObject is WebException) { WebException ex = e.ExceptionObject as WebException; /*RootFrame.Dispatcher.BeginInvoke(() => * { * MessageBox.Show(ex.Message + "\n\nAre you connected to the network?", "Error Contacting Server", MessageBoxButton.OK); * });*/ } else { LittleWatson.ReportException(e.ExceptionObject, "Application_UnhandledException()"); RootFrame.Dispatcher.BeginInvoke(() => { LittleWatson.CheckForPreviousException(false); }); } e.Handled = true; if (System.Diagnostics.Debugger.IsAttached) { // An unhandled exception has occurred; break into the debugger System.Diagnostics.Debugger.Break(); } }
// Load data private void MainPage_Loaded(object sender, RoutedEventArgs e) { // Checks if there was an exception during previous run LittleWatson.CheckForPreviousException(true); if (PopularPictures.ItemsSource == null) { GlobalLoading.Instance.IsLoading = true; Dispatcher.BeginInvoke(() => PopularPictures.DataContext = App.PopularPictures); } if (recentPictures.ItemsSource == null) { Dispatcher.BeginInvoke(() => recentPictures.ItemsSource = App.RecentPictures); } if (FavoritePictures.ItemsSource == null) { Dispatcher.BeginInvoke(() => FavoritePictures.DataContext = App.FavoritedUserPictures); } }