protected override void EndProcessing() { _logger.Log(PsesLogLevel.Diagnostic, "Beginning EndProcessing block"); try { // First try to remove PSReadLine to decomplicate startup // If PSReadLine is enabled, it will be re-imported later RemovePSReadLineForStartup(); // Create the configuration from parameters EditorServicesConfig editorServicesConfig = CreateConfigObject(); var sessionFileWriter = new SessionFileWriter(_logger, SessionDetailsPath); _logger.Log(PsesLogLevel.Diagnostic, "Session file writer created"); using (var psesLoader = EditorServicesLoader.Create(_logger, editorServicesConfig, sessionFileWriter, _loggerUnsubscribers)) { _logger.Log(PsesLogLevel.Verbose, "Loading EditorServices"); psesLoader.LoadAndRunEditorServicesAsync().Wait(); } } catch (Exception e) { _logger.LogException("Exception encountered starting EditorServices", e); // Give the user a chance to read the message if they have a console if (!Stdio) { Host.UI.WriteLine("\n== Press any key to close terminal =="); Console.ReadKey(); } ThrowTerminatingError(new ErrorRecord(e, "PowerShellEditorServicesError", ErrorCategory.NotSpecified, this)); } finally { foreach (IDisposable disposableResource in _disposableResources) { disposableResource.Dispose(); } } }