// Code to execute on Unhandled Exceptions private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e) { App.AnalyticsInstance.saveObject(); if (System.Diagnostics.Debugger.IsAttached) { // An unhandled exception has occurred; break into the debugger System.Diagnostics.Debugger.Break(); } if (!IS_MARKETPLACE) { //Running on a device / emulator without debugging e.Handled = true; Error.Exception = e.ExceptionObject; Debug.WriteLine("UNHANDLED EXCEPTION : {0}", e.ExceptionObject.StackTrace); Deployment.Current.Dispatcher.BeginInvoke(() => { MessageBox.Show(e.ExceptionObject.ToString(), "Exception", MessageBoxButton.OK); //(RootVisual as Microsoft.Phone.Controls.PhoneApplicationFrame).Source = new Uri("/View/Error.xaml", UriKind.Relative); }); } if (IS_VIEWMODEL_LOADED) { int convs = 0; appSettings.TryGetValue <int>(HikeViewModel.NUMBER_OF_CONVERSATIONS, out convs); if (convs != 0 && App.ViewModel.ConvMap.Count == 0) { return; } ConversationTableUtils.saveConvObjectList(); } }
// Code to execute when the application is deactivated (sent to background) // This code will not execute when the application is closing private void Application_Deactivated(object sender, DeactivatedEventArgs e) { NetworkManager.turnOffNetworkManager = true; App.AnalyticsInstance.saveObject(); PhoneApplicationService.Current.State[LAUNCH_STATE] = _appLaunchState; if (IS_VIEWMODEL_LOADED) { int convs = 0; appSettings.TryGetValue <int>(HikeViewModel.NUMBER_OF_CONVERSATIONS, out convs); if (convs != 0 && App.ViewModel.ConvMap.Count == 0) { return; } ConversationTableUtils.saveConvObjectList(); } }
// Code to execute if a navigation fails private void RootFrame_NavigationFailed(object sender, NavigationFailedEventArgs e) { //MessageBoxResult result = MessageBox.Show("Exception :: ", e.ToString(), MessageBoxButton.OK); //if (result == MessageBoxResult.OK) if (System.Diagnostics.Debugger.IsAttached) { // A navigation has failed; break into the debugger System.Diagnostics.Debugger.Break(); } App.AnalyticsInstance.saveObject(); if (IS_VIEWMODEL_LOADED) { int convs = 0; appSettings.TryGetValue <int>(HikeViewModel.NUMBER_OF_CONVERSATIONS, out convs); if (convs != 0 && App.ViewModel.ConvMap.Count == 0) { return; } ConversationTableUtils.saveConvObjectList(); } }