From 47c313a26a57d4a117bfe83dbdacdedb85f3512a Mon Sep 17 00:00:00 2001 From: Asif Bacchus Date: Mon, 6 Sep 2021 15:45:06 -0600 Subject: [PATCH] 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 --- wakeup.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wakeup.ps1 b/wakeup.ps1 index ef1adb7..df5b2a9 100644 --- a/wakeup.ps1 +++ b/wakeup.ps1 @@ -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 \ No newline at end of file