Link to home
Start Free TrialLog in
Avatar of Mauro Cazabonnet
Mauro CazabonnetFlag for United States of America

asked on

While loop multiple conditions

Why wont the while loop break after the timeout in this example

$timeout = new-timespan -Seconds 10
$sw = [diagnostics.stopwatch]::StartNew()
$bool = $true

while (($sw.elapsed -lt $timeout) -or ($bool)){
    
 
    start-sleep -seconds 2
}
 
write-host "Timed out"

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Chris Dent
Chris Dent
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
It's perhaps worth noting that the second term in your condition is completely superfluous, but I assume it's part of something you're developing rather than the end result.
Avatar of Mauro Cazabonnet

ASKER

Right thx!!!