commit e4b9205cff88701b2ad1078dd8ed311ac716b8b6 parent 0c64cb8549d2239b3d813223a0365801dd32831f Author: yao-msft <50888816+yao-msft@users.noreply.github.com> Date: Thu, 29 Jun 2023 13:53:58 -0700 Force close sandbox server upon timeout (#3392) Diffstat:
| M | tools/CorrelationTestbed/Test-CorrelationInSandbox.ps1 | | | 14 | ++++++++++++-- |
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/tools/CorrelationTestbed/Test-CorrelationInSandbox.ps1 b/tools/CorrelationTestbed/Test-CorrelationInSandbox.ps1 @@ -115,12 +115,22 @@ function Close-WindowsSandbox { $sandboxServer = Get-Process 'WindowsSandbox' -ErrorAction SilentlyContinue $sandbox | Stop-Process - $sandbox | Wait-Process -Timeout 30 + $sandbox | Wait-Process -Timeout 120 # Also wait for the server to close if ($sandboxServer) { - $sandboxServer | Wait-Process -Timeout 30 + try + { + $sandboxServer | Wait-Process -Timeout 120 + } + catch [System.TimeoutException] + { + # Force stop the server if it does not automatically stop + $sandboxServer | Stop-Process + $sandboxServer | Wait-Process -Timeout 120 + } + } Write-Host