/// <summary> /// Blocks DebuggerStop event thread until exit debug mode is /// received from the client. /// </summary> private void OnEnterDebugMode(ManualResetEventSlim debugModeCompletedEvent) { Dbg.Assert(!debugModeCompletedEvent.IsSet, "Event should always be non-signaled here."); while (true) { debugModeCompletedEvent.Wait(); debugModeCompletedEvent.Reset(); if (_threadCommandProcessing != null) { // Process command. _threadCommandProcessing.DoInvoke(); _threadCommandProcessing = null; } else { // No command to process. Exit debug mode. break; } } }
/// <summary> /// ProcessCommand /// </summary> /// <param name="command">Command</param> /// <param name="output">Output</param> /// <returns></returns> public override DebuggerCommandResults ProcessCommand(PSCommand command, PSDataCollection<PSObject> output) { if (LocalDebugMode) { return _wrappedDebugger.Value.ProcessCommand(command, output); } if (!InBreakpoint || (_threadCommandProcessing != null)) { throw new PSInvalidOperationException( StringUtil.Format(DebuggerStrings.CannotProcessDebuggerCommandNotStopped)); } if (_processCommandCompleteEvent == null) { _processCommandCompleteEvent = new ManualResetEventSlim(false); } _threadCommandProcessing = new ThreadCommandProcessing(command, output, _wrappedDebugger.Value, _processCommandCompleteEvent); try { return _threadCommandProcessing.Invoke(_nestedDebugStopCompleteEvent); } finally { _threadCommandProcessing = null; } }