Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ public void WriteProgress(long sourceId, ProgressRecord record)
{
if (record == null)
{
Console.CursorVisible = true;
throw new ArgumentNullException("record");
}

Expand All @@ -80,14 +79,12 @@ public void WriteProgress(long sourceId, ProgressRecord record)
_console.Write(" ");
}
_console.WriteLine();
Console.CursorVisible = true;
}
else
{
Console.CursorVisible = false;
var statusLine = string.Format(Strings.ConsoleDataStream_WriteProgress_StatusLineInProgress, record.Activity, record.StatusDescription, record.CurrentOperation, record.SecondsRemaining);
// Subtract what's already known to be needed:
width -= statusLine.Length + 3;
width = Math.Max(1, width - (statusLine.Length + 3));

var chunkSize = (100 / width) + 1;

Expand Down
34 changes: 34 additions & 0 deletions src/CLU/Microsoft.ScenarioTests.CLU/ProgressTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

using System.Management.Automation;

namespace Microsoft.CLU.Test
{

[Cmdlet(VerbsCommon.Show, "Progress")]
public class ShowProgress: PSCmdlet
{
[Parameter()]
public int Steps{ get; set; }


protected override void ProcessRecord()
{
base.ProcessRecord();

var progRecord = new ProgressRecord(4711, "Testing progress", "Running");
WriteProgress(progRecord);
for (int step = 1; step <= Steps; ++step)
{
System.Threading.Thread.Sleep(100);
progRecord.PercentComplete = step * 100 / Steps;
WriteProgress(progRecord);
}
progRecord.RecordType = ProgressRecordType.Completed;
WriteProgress(progRecord);
}
}
}
4 changes: 3 additions & 1 deletion src/CLU/Microsoft.ScenarioTests.CLU/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
"dependencies": {
"Microsoft.NETCore": "5.0.1-beta-23516",
"Microsoft.NETCore.Platforms": "1.0.1-beta-23516",
"Microsoft.CSharp": "4.0.1-beta-23516"
"Microsoft.CSharp": "4.0.1-beta-23516",

"System.Threading.Thread": "4.0.0-beta-23516"
}
}
},
Expand Down