Skip to content

Commit 8cd2c2f

Browse files
daviwilKayla Davis
authored andcommitted
Add timeout for host process /waitForDebugger flag
This change adds a 15 second timeout for the /waitForDebugger flag in debug builds. This prevents hangs when Visual Studio can't attach to the process automatically when debugging tests.
1 parent bede0e9 commit 8cd2c2f

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/PowerShellEditorServices.Host/Program.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,12 @@ static void Main(string[] args)
2828
// Should we wait for the debugger before starting?
2929
if (waitForDebugger)
3030
{
31-
while (!Debugger.IsAttached)
31+
// Wait for 15 seconds and then continue
32+
int waitCountdown = 15;
33+
while (!Debugger.IsAttached && waitCountdown > 0)
3234
{
33-
Thread.Sleep(500);
35+
Thread.Sleep(1000);
36+
waitCountdown--;
3437
}
3538
}
3639

test/PowerShellEditorServices.Test.Host/LanguageServiceManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public void Start()
4040
{
4141
FileName = "Microsoft.PowerShell.EditorServices.Host.exe",
4242
Arguments = languageServiceArguments,
43-
CreateNoWindow = false,
43+
CreateNoWindow = true,
4444
UseShellExecute = false,
4545
RedirectStandardInput = true,
4646
RedirectStandardOutput = true,

0 commit comments

Comments
 (0)