Skip to content

Forwarding progress stream changes from Foreach-Object -Parallel runspaces - #14271

Merged
Ilya (iSazonov) merged 3 commits into
PowerShell:masterfrom
powercode:parallel_progress
Jul 31, 2021
Merged

Ilya (iSazonov) merged 3 commits into
PowerShell:masterfrom
powercode:parallel_progress

Conversation

@powercode

@powercode Staffan Gustafsson (powercode) commented Nov 26, 2020 •

Copy link
Copy Markdown
Collaborator

PR Summary

Forwarding progress stream changes from Foreach-Object -Parallel runspaces in the same way as the other streams.
#14254

PR Context

Now looks like this.
That it doesn't render perfectly is a separate issue.

function Show-Progress {
    param([int] $ThrottleLimit = 4)
    $parentId = 100
    Write-Progress -Id $parentId -Activity Parent -status Parallel
    1..20 | Foreach-Object -ThrottleLimit $ThrottleLimit -Parallel {
        $progress = @{
            Id               = $_
            Activity         = "Activity $_"
            CurrentOperation = "Operation $_"
            PercentComplete  = 0
            ParentId         = $using:parentId
        }
        
        Write-Progress @progress
        Start-sleep -Seconds 1
        $id
        foreach ($p in 1..100) {
            $progress.PercentComplete = $p
            Write-Progress @progress
            Start-Sleep -Milliseconds 100
        }
        start-sleep -Seconds 1
        Write-Progress @progress -Completed
    }         
    Write-Progress -Id 1 -Acti Parent -completed
}

image

image

The test looks different as the Progress stream is not forwardable. So the API is used instead.

PR Checklist

@ghost ghost assigned Ilya (iSazonov) Nov 26, 2020
@iSazonov Ilya (iSazonov) added the CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log label Nov 26, 2020
@iSazonov

Copy link
Copy Markdown
Collaborator

Staffan Gustafsson (@powercode) Please add some example scripts/screenshot.
And we need test(s).

@ghost ghost added the Review - Needed The PR is being reviewed label Dec 4, 2020
@ghost

Copy link
Copy Markdown

This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days.
Maintainer, please provide feedback and/or mark it as Waiting on Author

@tlsalex

tlsalex commented Jan 25, 2021

Copy link
Copy Markdown

A few days had passed , the fix still on its way ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM Staffan Gustafsson (@powercode) Thanks for adding this!

…bject-Parallel.Tests.ps1

Co-authored-by: Ilya <darpa@yandex.ru>
@tlsalex

tlsalex commented Jul 28, 2021

Copy link
Copy Markdown

34 successful and 1 expected checks

what action need to take for the 1 "expected checks" ?

@tlsalex

tlsalex commented Jul 31, 2021

Copy link
Copy Markdown

Staffan Gustafsson (@powercode) could you help to compile latest Powershell code but with your fix for windows x64 ? I want to use this feature before official release . I am not a code man , I don't know how to compile it. thanks !

@ghost ghost removed the Review - Needed The PR is being reviewed label Jul 31, 2021
@iSazonov

Copy link
Copy Markdown
Collaborator

tlsalex You can download build.zip from CIs.

@iSazonov

Copy link
Copy Markdown
Collaborator

/rebase

@iSazonov Ilya (iSazonov) changed the title Fixes #14254: foreach -Parallel does not display progress Forwarding progress stream changes from Foreach-Object -Parallel runspaces Jul 31, 2021
@iSazonov
Ilya (iSazonov) merged commit 1bfa1c3 into PowerShell:master Jul 31, 2021
@iSazonov Ilya (iSazonov) added this to the 7.2.0-preview.9 milestone Jul 31, 2021
@powercode
Staffan Gustafsson (powercode) deleted the parallel_progress branch August 16, 2021 14:07
@ghost

Copy link
Copy Markdown

🎉v7.2.0-preview.9 has been released which incorporates this pull request.:tada:

Handy links:

@ghost

Copy link
Copy Markdown

🎉v7.2.0-preview.10 has been released which incorporates this pull request.:tada:

Handy links:

Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants