Beispiel #1
0
        private IWpfConsole GetWpfConsole()
        {
            PowerConsoleWindow powershellConsole = null;
            var timer = Stopwatch.StartNew();

            while (powershellConsole?.ActiveHostInfo?.WpfConsole == null)
            {
                try
                {
                    var outputConsoleWindow = ServiceLocator.GetInstance <IPowerConsoleWindow>();
                    powershellConsole = outputConsoleWindow as PowerConsoleWindow;
                }
                catch when(timer.Elapsed < _timeout)
                {
                    // Retry until the console is loaded
                    Thread.Sleep(100);
                }
            }

            return(powershellConsole.ActiveHostInfo.WpfConsole);
        }
Beispiel #2
0
        /// <summary>
        /// Called to retrieve current combo item name or to select a new item.
        /// </summary>
        private void Projects_Exec(object sender, EventArgs e)
        {
            OleMenuCmdEventArgs args = e as OleMenuCmdEventArgs;

            if (args != null)
            {
                if (args.InValue != null && args.InValue is int)
                {
                    // Selected a default projects
                    int index = (int)args.InValue;
                    if (index >= 0 && index < PowerConsoleWindow.AvailableProjects.Length)
                    {
                        PowerConsoleWindow.SetDefaultProjectIndex(index);
                    }
                }
                else if (args.OutValue != IntPtr.Zero)
                {
                    string displayName = PowerConsoleWindow.DefaultProject ?? string.Empty;
                    Marshal.GetNativeVariantForObject(displayName, args.OutValue);
                }
            }
        }
        private async Task <IWpfConsole> GetWpfConsole()
        {
            await NuGetUIThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            PowerConsoleWindow powershellConsole = null;
            var timer = Stopwatch.StartNew();

            while (powershellConsole?.ActiveHostInfo?.WpfConsole == null)
            {
                try
                {
                    var outputConsoleWindow = ServiceLocator.GetInstance <IPowerConsoleWindow>();
                    powershellConsole = outputConsoleWindow as PowerConsoleWindow;
                }
                catch when(timer.Elapsed < _timeout)
                {
                    // Retry until the console is loaded
                    Thread.Sleep(100);
                }
            }

            return(powershellConsole?.ActiveHostInfo?.WpfConsole);
        }