Ejemplo n.º 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);
                }
            }
        }
Ejemplo n.º 2
0
 public void RunWorkbench(WorkbenchSettings settings)
 {
     if (settings.RunOnNewThread)
     {
         Thread t = new Thread(RunWorkbenchInternal);
         t.SetApartmentState(ApartmentState.STA);
         t.Name = "StartUp";
         t.Start(settings);
     }
     else
     {
         RunWorkbenchInternal(settings);
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Initializes the workbench (create the MainForm instance, construct menu from AddInTree etc.)
 /// and runs it using the supplied settings.
 /// This starts a new message loop for the workbench. By default the message loop
 /// is created on a new thread, but you can change the settings so that
 /// it is created on the thread calling RunWorkbench.
 /// In that case, RunWorkbench will block until SharpDevelop is shut down!
 /// </summary>
 public void RunWorkbench(WorkbenchSettings settings)
 {
     if (settings == null)
     {
         throw new ArgumentNullException("settings");
     }
     if (initStatus == FWInitStatus.CoreInitialized)
     {
         initStatus = FWInitStatus.Busy;
         helper.RunWorkbench(settings);
         if (settings.RunOnNewThread)
         {
             initStatus = FWInitStatus.WorkbenchInitialized;
         }
     }
     else
     {
         throw new InvalidOperationException();
     }
 }