private void StartConsoleSession(FrameworkElement consolePane)
        {
            if (WpfConsole != null && WpfConsole.Content == consolePane && WpfConsole.Host != null)
            {
                try
                {
                    if (WpfConsole.Dispatcher.IsStartCompleted)
                    {
                        OnDispatcherStartCompleted();
                        // if the dispatcher was started before we reach here,
                        // it means the dispatcher has been in read-only mode (due to _startedWritingOutput = false).
                        // enable key input now.
                        WpfConsole.Dispatcher.AcceptKeyInput();
                    }
                    else
                    {
                        WpfConsole.Dispatcher.StartCompleted  += (sender, args) => OnDispatcherStartCompleted();
                        WpfConsole.Dispatcher.StartWaitingKey += OnDispatcherStartWaitingKey;
                        WpfConsole.Dispatcher.Start();
                    }
                }
                catch (Exception x)
                {
                    // hide the text "initialize host" when an error occurs.
                    ConsoleParentPane.NotifyInitializationCompleted();

                    WpfConsole.WriteLine(x.GetBaseException().ToString());
                    ExceptionHelper.WriteToActivityLog(x);
                }
            }
            else
            {
                ConsoleParentPane.NotifyInitializationCompleted();
            }
        }
Exemple #2
0
        public override void OnToolWindowCreated()
        {
            // Register key bindings to use in the editor
            var  windowFrame = (IVsWindowFrame)Frame;
            Guid cmdUi       = VSConstants.GUID_TextEditorFactory;

            windowFrame.SetGuidProperty((int)__VSFPROPID.VSFPROPID_InheritKeyBindings, ref cmdUi);

            // pause for a tiny moment to let the tool window open before initializing the host
            var timer = new DispatcherTimer();

            timer.Interval = TimeSpan.FromMilliseconds(0);
            timer.Tick    += (o, e) =>
            {
                timer.Stop();

                // all exceptions from the timer thread should be caught to avoid crashing VS
                try
                {
                    LoadConsoleEditor();
                }
                catch (Exception x)
                {
                    // hide the text "initialize host" when an error occurs.
                    ConsoleParentPane.NotifyInitializationCompleted();

                    ExceptionHelper.WriteToActivityLog(x);
                }
            };
            timer.Start();

            base.OnToolWindowCreated();
        }
Exemple #3
0
        private void OnDispatcherStartCompleted()
        {
            ConsoleParentPane.NotifyInitializationCompleted();

            // force the UI to update the toolbar
            VsUIShell.UpdateCommandUI(0 /* false = update UI asynchronously */);
        }
        private void OnDispatcherStartCompleted()
        {
            WpfConsole.Dispatcher.StartWaitingKey -= OnDispatcherStartWaitingKey;

            ConsoleParentPane.NotifyInitializationCompleted();

            // force the UI to update the toolbar
            VsUIShell.UpdateCommandUI(0 /* false = update UI asynchronously */);

            NuGetEventTrigger.Instance.TriggerEvent(NuGetEvent.PackageManagerConsoleLoaded);
        }
Exemple #5
0
        private async Task OnDispatcherStartCompletedAsync()
        {
            WpfConsole.Dispatcher.StartWaitingKey -= OnDispatcherStartWaitingKey;

            ConsoleParentPane.NotifyInitializationCompleted();

            await NuGetUIThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            // force the UI to update the toolbar
            IVsUIShell vsUIShell = await AsyncServiceProvider.GlobalProvider.GetServiceAsync <IVsUIShell, IVsUIShell>(throwOnFailure : false);

            vsUIShell.UpdateCommandUI(0 /* false = update UI asynchronously */);
        }
Exemple #6
0
        private async Task OnDispatcherStartCompletedAsync()
        {
            WpfConsole.Dispatcher.StartWaitingKey -= OnDispatcherStartWaitingKey;

            ConsoleParentPane.NotifyInitializationCompleted();

            await NuGetUIThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            // force the UI to update the toolbar
            IVsUIShell vsUIShell = await AsyncServiceProvider.GlobalProvider.GetServiceAsync <IVsUIShell>();

            vsUIShell.UpdateCommandUI(0 /* false = update UI asynchronously */);

            NuGetEventTrigger.Instance.TriggerEvent(NuGetEvent.PackageManagerConsoleLoaded);
        }
Exemple #7
0
        private void OnDispatcherStartCompleted()
        {
            WpfConsole.Dispatcher.StartWaitingKey -= OnDispatcherStartWaitingKey;

            ConsoleParentPane.NotifyInitializationCompleted();

            NuGetUIThreadHelper.JoinableTaskFactory.Run(async() =>
            {
                await NuGetUIThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

                // force the UI to update the toolbar
                VsUIShell.UpdateCommandUI(0 /* false = update UI asynchronously */);
            });

            NuGetEventTrigger.Instance.TriggerEvent(NuGetEvent.PackageManagerConsoleLoaded);
        }
Exemple #8
0
        private void StartConsoleSession(FrameworkElement consolePane)
        {
            if (WpfConsole != null && WpfConsole.Content == consolePane && WpfConsole.Host != null)
            {
                try
                {
                    if (WpfConsole.Dispatcher.IsStartCompleted)
                    {
                        OnDispatcherStartCompleted();
                    }
                    else
                    {
                        WpfConsole.Dispatcher.StartCompleted += (sender, args) => OnDispatcherStartCompleted();
                        WpfConsole.Dispatcher.Start();
                    }
                } catch (Exception x)
                {
                    // hide the text "initialize host" when an error occurs.
                    ConsoleParentPane.NotifyInitializationCompleted();

                    WpfConsole.WriteLine(x.ToString());
                }
            }
        }
Exemple #9
0
 private void OnDispatcherStartWaitingKey(object sender, EventArgs args)
 {
     WpfConsole.Dispatcher.StartWaitingKey -= OnDispatcherStartWaitingKey;
     // we want to hide the text "initialize host..." when waiting for key input
     ConsoleParentPane.NotifyInitializationCompleted();
 }