refactor(wakeup): rewrite connectivity check timer loop

- use do loop to run at least one check
- check total time vs timeout in trailing while condition
This commit is contained in:
Asif Bacchus 2021-09-06 15:45:06 -06:00
parent 5332818990
commit 47c313a26a

View File

@ -161,11 +161,11 @@ for ($i = $ConnectivityCheckDelay; $i -gt 0; $i--) {
Write-Progress -Activity "Waiting for computer(s) to wake-up..." -Completed
# iterate computers and test connectivity
# TODO: run multiple connectivity tests as needed, spaced evenly apart up to max timeout THEN fail
# TODO: report error/fail only after final run
# TODO: run connectivity test as background job
$connCheckTotalTime = 0
$removeFromTargetComputers.Clear()
while ($connCheckTotalTime -le $ConnectivityCheckTimeout -and $targetComputers.Count -gt 0)
do
{
$targetComputers | ForEach-Object {
$name = $_.name
@ -213,7 +213,7 @@ while ($connCheckTotalTime -le $ConnectivityCheckTimeout -and $targetComputers.C
Write-Progress -Activity "Waiting for next connectivity check..." -Completed
$connCheckTotalTime += $ConnectivityCheckInterval
}
}
} while ($connCheckTotalTime -le $ConnectivityCheckTimeout -and $targetComputers.Count -gt 0)
# exit gracefully
exitGracefully