Skip to content

Commit 7813e32

Browse files
Merge branch 'AzureRM.Compute.4.3.1' into sergey-get-image-info
2 parents 75c4f87 + f746121 commit 7813e32

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

src/ResourceManager/Compute/Commands.Compute/Strategies/AsyncCmdletExtensions.cs

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ public static void StartAndWait(
3131
this Cmdlet cmdlet, Func<IAsyncCmdlet, Task> createAndStartTask)
3232
{
3333
var asyncCmdlet = new AsyncCmdlet(cmdlet);
34+
string previousX = null;
35+
string previousOperation = null;
3436
asyncCmdlet.Scheduler.Wait(
3537
createAndStartTask(asyncCmdlet),
3638
() =>
@@ -51,17 +53,25 @@ public static void StartAndWait(
5153
var percent = (int)(progress * 100.0);
5254
var r = new[] { "|", "/", "-", "\\" };
5355
var x = r[DateTime.Now.Second % 4];
54-
cmdlet.WriteProgress(
55-
new ProgressRecord(
56-
0,
57-
"Creating Azure resources",
58-
percent + "% " + x)
59-
{
60-
CurrentOperation = activeTasks.Count > 0
61-
? "Creating " + string.Join(", ", activeTasks) + "."
62-
: null,
63-
PercentComplete = percent,
64-
});
56+
var operation = activeTasks.Count > 0
57+
? "Creating " + string.Join(", ", activeTasks) + "."
58+
: null;
59+
60+
// write progress only if it's changed.
61+
if (x != previousX || operation != previousOperation)
62+
{
63+
cmdlet.WriteProgress(
64+
new ProgressRecord(
65+
0,
66+
"Creating Azure resources",
67+
percent + "% " + x)
68+
{
69+
CurrentOperation = operation,
70+
PercentComplete = percent,
71+
});
72+
previousX = x;
73+
previousOperation = operation;
74+
}
6575
}
6676
});
6777
}

0 commit comments

Comments
 (0)