private void Shutdown(bool updating) { // Clear temporary files TemporaryFileServiceFactory.get().shutdown(); try { RendezvousFactory.instance().quit(); } catch (SystemException se) { Logger.warn("No Bonjour support available", se); } PreferencesFactory.get().setProperty("uses", PreferencesFactory.get().getInteger("uses") + 1); try { PreferencesFactory.get().save(); } catch (UnauthorizedAccessException unauthorizedAccessException) { Logger.fatal("Could not save preferences", unauthorizedAccessException); } if (_updater != null && !updating) { _updater.unregister(); } }
/// <summary> /// Default constructor. /// </summary> private MainController() { InitializeAppProperties(); // Explicitly set SaveMySettingsOnExit to false, preventing UnauthorizedAccessException after Close // if no permission for writing to %AppData% SaveMySettingsOnExit = false; Startup += ApplicationDidFinishLaunching; StartupNextInstance += StartupNextInstanceHandler; Shutdown += delegate { // Clear temporary files TemporaryFileServiceFactory.get().shutdown(); try { RendezvousFactory.instance().quit(); } catch (SystemException se) { Logger.warn("No Bonjour support available", se); } PreferencesFactory.get().setProperty("uses", PreferencesFactory.get().getInteger("uses") + 1); try { PreferencesFactory.get().save(); } catch (UnauthorizedAccessException unauthorizedAccessException) { Logger.fatal("Could not save preferences", unauthorizedAccessException); } if (_updater != null) { _updater.unregister(); } }; }