/// <summary>
        /// Initializes an new instance of the ThreadController class. This constructor should only
        /// ever been called from the thread it is meant to control.
        /// </summary>
        /// <param name="nestFrame">The parent PromptNestFrame object.</param>
        internal ThreadController(PromptNestFrame nestFrame)
        {
            _nestFrame           = nestFrame;
            PipelineRequestQueue = new AsyncQueue <IPipelineExecutionRequest>();
            FrameExitTask        = new TaskCompletionSource <DebuggerResumeAction>();
            ManagedThreadId      = Thread.CurrentThread.ManagedThreadId;

            // If the debugger stop is triggered on a thread with no default runspace we
            // shouldn't attempt to route commands to it.
            IsPipelineThread = Runspace.DefaultRunspace != null;
        }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PromptNest" /> class.
        /// </summary>
        /// <param name="powerShellContext">
        /// The <see cref="PowerShellContext" /> to track prompt status for.
        /// </param>
        /// <param name="initialPowerShell">
        /// The <see cref="PowerShell" /> instance for the first frame.
        /// </param>
        /// <param name="consoleReader">
        /// The input handler.
        /// </param>
        /// <param name="versionSpecificOperations">
        /// The <see cref="IVersionSpecificOperations" /> for the calling
        /// <see cref="PowerShellContext" /> instance.
        /// </param>
        /// <remarks>
        /// This constructor should only be called when <see cref="PowerShellContext.CurrentRunspace" />
        /// is set to the initial runspace.
        /// </remarks>
        internal PromptNest(
            PowerShellContextService powerShellContext,
            PowerShell initialPowerShell,
            IHostInput consoleReader,
            IVersionSpecificOperations versionSpecificOperations)
        {
            _versionSpecificOperations = versionSpecificOperations;
            _consoleReader             = consoleReader;
            _powerShellContext         = powerShellContext;
            _frameStack = new ConcurrentStack <PromptNestFrame>();
            _frameStack.Push(
                new PromptNestFrame(
                    initialPowerShell,
                    NewHandleQueue()));

            var readLineShell = PowerShell.Create();

            readLineShell.Runspace = powerShellContext.CurrentRunspace.Runspace;
            _readLineFrame         = new PromptNestFrame(
                readLineShell,
                new AsyncQueue <RunspaceHandle>());

            ReleaseRunspaceHandleImpl(isReadLine: true);
        }