Skip to content

Migrate REST API progress status to use Write-Progress - #167

Merged
Howard Wolosky (HowardWolosky) merged 1 commit into
microsoft:masterfrom
HowardWolosky:progress
May 12, 2020
Merged

Howard Wolosky (HowardWolosky) merged 1 commit into
microsoft:masterfrom
HowardWolosky:progress

Conversation

@HowardWolosky

@HowardWolosky Howard Wolosky (HowardWolosky) commented May 12, 2020 •

Copy link
Copy Markdown
Contributor

When this module was originally written, it used a special feature
of Write-Host in order to re-write the previously written line, in
order to show the user an indeterminate waiting indicator while the
module awaited a response from the server for a REST API request.

Unfortunately, this doesn't work well with all PowerShell hosts
(PowerShell ISE is one notable example). This approach had been taken
originally as it had seemed odd to use Write-Progress (which displays
an absolute progress percentage) for something where we didn't absolutely
know the final duration.

This change migrates the module over to use Write-Progress, and simply
loops through the displayed percentage completed in the same manor that
it loops through and shows an animation.

This method should achieve the same desired goal (letting users know
that something is happening and that they just need to wait a bit
longer) in a more standards-approved way.

Resolves #119

When this module was originally written, it used a special feature
of Write-Host in order to re-write the previously written line, in
order to show the user an indeterminate waiting indicator while the
module awaited a response from the server for a REST API request.

Unfortunately, this doesn't work well with all PowerShell hosts
(PowerShell ISE is one notable example).  This approach had been taken
originally as it had seemed odd to use Write-Progress (which displays
an absolute progress percentage) for something where we didn't absolutely
know the final duration.

This change migrates the module over to use Write-Progress, and simply
loops through the displayed percentage completed in the same manor that
it loops through and shows an animation.

This method should achieve the same desired goal (letting users know
that something is happening and that they just need to wait a bit
longer) in a more standards-approved way.

Resolve microsoft#119
@HowardWolosky
Howard Wolosky (HowardWolosky) merged commit 992f678 into microsoft:master May 12, 2020
@StartAutomating

Copy link
Copy Markdown

Sorry for letting this fall of my radar.

Taking a brief look at implementation, I don't see where you send -Completed message to Write-Progress.

This will cause progress bars to stay visible while any other commands in the script execute. E.g. if you ran a Get- that returned many results, and piped to an expensive Foreach-Object, your progress bar wouldn't go away until the Foreach-Object ended.

Sorry to let this drift off the radar again. Thanks for improving your Write-Progress experience either way.

@HowardWolosky

Copy link
Copy Markdown
Contributor Author

Thanks for the feedback. Putting out a fix now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Progress is Incorrectly Displayed

2 participants