Dispose() public method

public Dispose ( ) : void
return void
Example #1
0
        public async Task <IInteractiveWindowVisualComponent> GetOrCreateVisualComponent(IInteractiveWindowComponentContainerFactory componentContainerFactory, int instanceId = 0)
        {
            Shell.AssertIsOnMainThread();

            if (ActiveWindow != null)
            {
                // Right now only one instance of interactive window is allowed
                if (instanceId != 0)
                {
                    throw new InvalidOperationException("Right now only one instance of interactive window is allowed");
                }

                return(ActiveWindow);
            }

            var evaluator = new RInteractiveEvaluator(RSession, History, Connections, Shell, _settings);

            ActiveWindow = componentContainerFactory.Create(instanceId, evaluator);
            var interactiveWindow = ActiveWindow.InteractiveWindow;

            interactiveWindow.TextView.Closed += (_, __) => evaluator.Dispose();
            _operations.InteractiveWindow      = interactiveWindow;
            await interactiveWindow.InitializeAsync();

            ActiveWindow.Container.UpdateCommandStatus(true);
            return(ActiveWindow);
        }
        private async Task CreateVisualComponentAsync(int instanceId)
        {
            var factory   = Services.GetService <IInteractiveWindowComponentContainerFactory>();
            var evaluator = new RInteractiveEvaluator(RSessions, RSession, History, Connections, Services, _settings, Console);

            var window            = factory.Create(instanceId, evaluator, RSessions);
            var interactiveWindow = window.InteractiveWindow;

            interactiveWindow.TextView.Closed += (_, __) => evaluator.Dispose();
            _operations.InteractiveWindow      = interactiveWindow;

            if (!RSessions.HasBroker)
            {
                var connectedToBroker = await Connections.TryConnectToPreviouslyUsedAsync();

                if (!connectedToBroker)
                {
                    var showConnectionsWindow = Connections.RecentConnections.Any();
                    if (!showConnectionsWindow)
                    {
                        var message = Resources.NoLocalR.FormatInvariant(Environment.NewLine + Environment.NewLine,
                                                                         Environment.NewLine);
                        var ui = Services.UI();
                        showConnectionsWindow = ui.ShowMessage(message, MessageButtons.YesNo) == MessageButtons.No;
                    }

                    if (!showConnectionsWindow)
                    {
                        var installer = Services.GetService <IMicrosoftRClientInstaller>();
                        installer.LaunchRClientSetup(Services);
                    }
                    else
                    {
                        var toolWindows = Services.GetService <IRInteractiveWorkflowToolWindowService>();
                        toolWindows.Connections().Show(focus: false, immediate: false);
                    }
                }
            }

            await interactiveWindow.InitializeAsync();

            RSession.RestartOnBrokerSwitch = true;

            ActiveWindow = window;
            ActiveWindow.Container.UpdateCommandStatus(true);
            _visualComponentTcs.SetResult(ActiveWindow);
            ActiveWindowChanged?.Invoke(this, new ActiveWindowChangedEventArgs(window));
        }
Example #3
0
        private async Task CreateVisualComponentAsync(int instanceId) {
            var factory = Shell.ExportProvider.GetExportedValue<IInteractiveWindowComponentContainerFactory>();
            var evaluator = new RInteractiveEvaluator(RSessions, RSession, History, Connections, Shell, _settings, new InteractiveWindowConsole(this));

            var window = factory.Create(instanceId, evaluator, RSessions);
            var interactiveWindow = window.InteractiveWindow;
            interactiveWindow.TextView.Closed += (_, __) => evaluator.Dispose();
            _operations.InteractiveWindow = interactiveWindow;

            if (!RSessions.HasBroker) {
                var connectedToBroker = await Connections.TryConnectToPreviouslyUsedAsync();
                if (!connectedToBroker) {
                    var showConnectionsWindow = Connections.RecentConnections.Any();
                    if (!showConnectionsWindow){
                        var message = Resources.NoLocalR.FormatInvariant(Environment.NewLine + Environment.NewLine, Environment.NewLine);
                        showConnectionsWindow = Shell.ShowMessage(message, MessageButtons.YesNo) == MessageButtons.Yes;
                    }

                    if (!showConnectionsWindow) {
                        var installer = Shell.ExportProvider.GetExportedValue<IMicrosoftRClientInstaller>();
                        installer.LaunchRClientSetup(Shell);
                    } else {
                        Connections.GetOrCreateVisualComponent().Container.Show(focus: false, immediate: false);
                    }
                }
            }

            await interactiveWindow.InitializeAsync();

            ActiveWindow = window;
            ActiveWindow.Container.UpdateCommandStatus(true);
            _visualComponentTcs.SetResult(ActiveWindow);
            ActiveWindowChanged?.Invoke(this, new ActiveWindowChangedEventArgs(window));
        }