-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
I appreciate the progress bar improvements since the PowerShell 5 era. #14414's small progress bars I think especially improve the experience.
The code below starts 100 jobs each of which takes about a second to complete. Each job has a progress updated at 10 millisecond intervals. After the jobs complete, the script sleeps for 1000 seconds. At first the progress bars seem to complete as expected. When the jobs complete, however, a number of progress bars with differing completion percentages reappear and remain indefinitely.
Note that reducing the value of -Milliseconds seems to increase the number of progress bars that reappear.
I see #3366 mentions some progress bar limitations but that issue predates #14414, and I'm not sure which still apply. This all leads me to the following questions:
- Is the repro here expected, as intended, or as designed?
- Is there a workaround to get the progress bars to clear reliably?
.\repro.ps1
$jobs =
$(foreach ($iteration in 1..100) {
Start-ThreadJob `
-StreamingHost $Host `
-ArgumentList $iteration `
-ScriptBlock {
param($iteration)
$id = Get-Random ([int]::MaxValue) -Minimum 0
1..100 |
% {
Write-Progress -Activity "Job $iteration Activity $_" -Id $id -PercentComplete $_
Start-Sleep -Milliseconds 10
}
Write-Progress -Id $id -Completed
}
})
$jobs | Wait-Job | Receive-Job -Keep
Start-Sleep -Seconds 1000Expected behavior
PS> .\repro.ps1
jobs completeActual behavior
PS> .\repro.ps1
jobs complete
Job 4 Activity 100 [Processing ...]
Job 3 Activity 100 [Processing ...]
Job 5 Activity 99 [Processing ...]
Job 7 Activity 100 [Processing ...]
Job 8 Activity 100 [Processing ...]
Job 15 Activity 99 [Processing ...]
Job 13 Activity 100 [Processing ...]
Job 14 Activity 99 [Processing ...]
Job 12 Activity 100 [Processing ...]
Job 17 Activity 100 [Processing ...]
Job 24 Activity 99 [Processing ...]
Job 39 Activity 100 [Processing ...]
Job 43 Activity 100 [Processing ...]
Job 44 Activity 99 [Processing ...]
Job 49 Activity 100 [Processing ...]
Job 48 Activity 100 [Processing ...]
Job 55 Activity 100 [Processing ...]
Job 57 Activity 100 [Processing ...]
Job 64 Activity 98 [Processing ...]
Job 63 Activity 99 [Processing ...]
Job 68 Activity 100 [Processing ...]
Job 70 Activity 99 [Processing ...]
Job 69 Activity 99 [Processing ...]
Job 72 Activity 100 [Processing ...]
Job 75 Activity 100 [Processing ...]
Job 78 Activity 100 [Processing ...]
Job 77 Activity 100 [Processing ...]
Job 82 Activity 100 [Processing ...]
Job 83 Activity 100 [Processing ...]
Job 84 Activity 100 [Processing ...]
Job 88 Activity 100 [Processing ...]
Job 87 Activity 100 [Processing ...]
Job 90 Activity 99 [Processing ...]
Job 89 Activity 99 [Processing ...]
Job 94 Activity 100 [Processing ...]
Job 93 Activity 100 [Processing ...]
Job 100 Activity 100 [Processing ...]
Job 98 Activity 99 [Processing ...]
Job 99 Activity 99 [Processing ...]Error details
No response
Environment data
Name Value
---- -----
PSVersion 7.4.6
PSEdition Core
GitCommitId 7.4.6
OS Microsoft Windows 10.0.22631
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0