示例#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);
                }
            }
        }
示例#2
0
        private static void RunWorkbench(StartupSettings wbSettings, Action BeforeRunWorkbench, Action WorkbenchClosed)
        {
            var wbc = new WorkbenchStartup();

            Current.Log.Info("Initializing workbench...");
            wbc.InitializeWorkbench();

            RunWorkbenchInitializedCommands();

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

            // finally start the workbench.
            try
            {
                BeforeRunWorkbench?.Invoke();
                if (Debugger.IsAttached)
                {
                    wbc.Run(wbSettings);
                }
                else
                {
                    try
                    {
                        wbc.Run(wbSettings);
                    }
                    catch (Exception ex)
                    {
                        exception = ex;
                    }
                }
            }
            finally
            {
            }
            Current.Log.Info("Finished running workbench.");
            WorkbenchClosed?.Invoke();
            if (exception != null)
            {
                const string errorText = "Unhandled exception terminated the workbench";
                Current.Log.Fatal(exception);
                if (wbSettings.UseExceptionBoxForErrorHandler)
                {
                    new ExceptionBox(exception, errorText, true).ShowDialog();
                }
                else
                {
                    throw new RunWorkbenchException(errorText, exception);
                }
            }
        }
示例#3
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 {
					// see IShutdownService.Shutdown for a description of the shut down procedure
					WorkbenchSingleton.OnWorkbenchUnloaded();
					var propertyService = SD.PropertyService;
					var shutdownService = (ShutdownService)SD.ShutdownService;
					shutdownService.WaitForBackgroundTasks();
					((IDisposable)SD.Services).Dispose(); // dispose all services
					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);
				}
			}
		}