static void RemarkOnException_GUI_THREAD(Exception ex) { try { Logging.Error(ex); UnhandledExceptionMessageBox.DisplayException(ex); } catch (Exception ex2) { Logging.Error(ex2, "Exception thrown in top level error handler!!"); } }
private void SynchronizeMetadata_INTERNAL_BACKGROUND(Library library, bool restricted_metadata_sync, bool is_readonly) { Dictionary <string, string> historical_sync_file = HistoricalSyncFile.GetHistoricalSyncFile(library); try { SynchronisationStates ss = SynchronisationStateBuilder.Build(library, historical_sync_file); SynchronisationAction sa = SynchronisationActionBuilder.Build(library, ss); SynchronisationExecutor.Sync(library, restricted_metadata_sync, is_readonly, historical_sync_file, sa); } catch (Exception ex) { UnhandledExceptionMessageBox.DisplayException(ex); } HistoricalSyncFile.PutHistoricalSyncFile(library, historical_sync_file); }
private static void RemarkOnException_GUI_THREAD(Exception ex, bool potentially_fatal) { try { Logging.Error(ex, "RemarkOnException_GUI_THREAD..."); // the garbage collection is not crucial for the functioning of the dialog itself, hence dump it into a worker thread. SafeThreadPool.QueueUserWorkItem(o => { // Collect all generations of memory. GC.WaitForPendingFinalizers(); GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced, true, true); }); bool isGDIfailureInXULrunner = ex.Message.Contains("A generic error occurred in GDI+"); const int EACCESS = unchecked ((int)0x80004005); if (isGDIfailureInXULrunner || ex.HResult == EACCESS) { potentially_fatal = false; } // do NOT display GDI+ errors as they are merely obnoxious and unresolvable anyway: if (!isGDIfailureInXULrunner) { UnhandledExceptionMessageBox.DisplayException(ex); } } catch (Exception ex2) { Logging.Error(ex2, "Exception thrown in top level error handler!!"); } if (potentially_fatal) { // signal the application to shutdown as an unhandled exception is a grave issue and nothing will be guaranteed afterwards. ShutdownableManager.Instance.Shutdown($"Exception received in top level error handler: {ex}"); // and terminate the Windows Message Loop if it hasn't already (in my tests, Qiqqa was stuck in there without a window to receive messages from at this point...) MainWindowServiceDispatcher.Instance.ShutdownQiqqa(suppress_exit_warning: true); } }