diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/StreamHelper.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/StreamHelper.cs index 43b42066cfa..62b50758558 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/StreamHelper.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/StreamHelper.cs @@ -289,16 +289,14 @@ internal static void WriteToStream(Stream input, Stream output, PSCmdlet cmdlet, ActivityId, WebCmdletStrings.WriteRequestProgressActivity, WebCmdletStrings.WriteRequestProgressStatus); + try { - do + while (!copyTask.Wait(1000, cancellationToken)) { record.StatusDescription = StringUtil.Format(WebCmdletStrings.WriteRequestProgressStatus, output.Position); cmdlet.WriteProgress(record); - - Task.Delay(1000).Wait(cancellationToken); } - while (!copyTask.IsCompleted && !cancellationToken.IsCancellationRequested); if (copyTask.IsCompleted) {