Exemple #1
0
        void RunWorkbenchInternal(object settings)
        {
            WorkbenchSettings wbSettings = (WorkbenchSettings)settings;

            WorkbenchStartup wbc = new WorkbenchStartup();

            LoggingService.Info("Initializing workbench...");
            wbc.InitializeWorkbench();

            RunWorkbenchInitializedCommands();

            LoggingService.Info("Starting workbench...");
            Exception exception = null;

            // finally start the workbench.
            try {
                callback.BeforeRunWorkbench();
                if (Debugger.IsAttached)
                {
                    wbc.Run(wbSettings.InitialFileList);
                }
                else
                {
                    try {
                        wbc.Run(wbSettings.InitialFileList);
                    } catch (Exception ex) {
                        exception = ex;
                    }
                }
            } finally {
                LoggingService.Info("Unloading services...");
                try {
                    WorkbenchSingleton.OnWorkbenchUnloaded();
                    PropertyService.Save();
                } catch (Exception ex) {
                    LoggingService.Warn("Exception during unloading", ex);
                    if (exception == null)
                    {
                        exception = ex;
                    }
                }
            }
            LoggingService.Info("Finished running workbench.");
            callback.WorkbenchClosed();
            if (exception != null)
            {
                const string errorText = "Unhandled exception terminated the workbench";
                LoggingService.Fatal(exception);
                if (useSharpDevelopErrorHandler)
                {
                    System.Windows.Forms.Application.Run(new ExceptionBox(exception, errorText, true));
                }
                else
                {
                    throw new RunWorkbenchException(errorText, exception);
                }
            }
        }