Exemple #1
0
        private static bool LaunchApplication(ApplicationPaths appPaths, NlogManager logManager)
        {
#if !DEBUG
            ILogger logger = logManager.GetLogger("App");
            try {
#endif
            using (var appHost = new ApplicationHost(appPaths, logManager)) {
                appHost.Init(new Progress<double>()).Wait();

                if (!appHost.TheaterConfigurationManager.Configuration.IsStartupWizardCompleted) {
                    bool completed = appHost.RunStartupWizard();

                    if (completed) {
                        appHost.TheaterConfigurationManager.Configuration.IsStartupWizardCompleted = true;
                        appHost.TheaterConfigurationManager.SaveConfiguration();

                        appHost.Restart().Wait();
                    } else {
                        appHost.Shutdown().Wait();
                    }
                } else {
                    appHost.RunUserInterface();
                }

                return appHost.RestartOnExit;
            }
#if !DEBUG
            } catch (Exception ex) {
                logger.ErrorException("Error launching application", ex);

                MessageBox.Show("There was an error launching Media Browser Theater: " + ex.Message);
                
                // Shutdown the app with an error code
                Environment.Exit(1);
                return false;
            }
#endif
        }
 static void process_Exited(object sender, EventArgs e)
 {
     _appHost.Shutdown();
 }