From ffa44a971bfce7a31e0d7508d3bd399d0a40fb87 Mon Sep 17 00:00:00 2001 From: Keith Hill Date: Wed, 10 Feb 2016 11:24:29 -0700 Subject: [PATCH] Easier launching of the debugging when /waitForDebugger passed in. OK been doing a lot of debugging of the debug adapater and this has been driving me crazy. Launch VSCode, open PS1 file so I can find the PID of the editor host. Then debug the script, hop over to VS attach to process, find the PID of the second host process (the debug instance) and attach. This new approach will just pop up a dialog box asking which instance of VS to use to debug. You can press NO to skip attaching the debugger and the script will continue to execute. --- src/PowerShellEditorServices.Host/Program.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/PowerShellEditorServices.Host/Program.cs b/src/PowerShellEditorServices.Host/Program.cs index efa4062c2..95b146c6d 100644 --- a/src/PowerShellEditorServices.Host/Program.cs +++ b/src/PowerShellEditorServices.Host/Program.cs @@ -27,15 +27,15 @@ static void Main(string[] args) "/waitForDebugger", StringComparison.InvariantCultureIgnoreCase)); - // Should we wait for the debugger before starting? if (waitForDebugger) { - // Wait for 25 seconds and then continue - int waitCountdown = 25; - while (!Debugger.IsAttached && waitCountdown > 0) + if (Debugger.IsAttached) { - Thread.Sleep(1000); - waitCountdown--; + Debugger.Break(); + } + else + { + Debugger.Launch(); } } #endif