Page 1 of 1

Console freeze

Posted: Fri Oct 11, 2024 5:16 am
by Philaubur
Hello,

I use the function below. It works well except that sometimes the console screen is frozen until a key is pressed.
Do you have any idea what is wrong.

function Start-Sleep-Progression($seconds) {
$doneDT = (Get-Date).AddSeconds($seconds)
while ($doneDT -gt (Get-Date)) {
$secondsLeft = $doneDT.Subtract((Get-Date)).TotalSeconds
$percent = ($seconds - $secondsLeft) / $seconds * 100
Write-Progress -Activity "Traitement" -Status "In Progress..." -SecondsRemaining -1 -PercentComplete $percent
[System.Threading.Thread]::Sleep(500)
}
Write-Progress -Activity "Traitement" -Status "In Progress..." -SecondsRemaining 0 -Completed
}