Skip to content

Commit 0a494c1

Browse files
committed
Return the lock to ConsoleHostUserInterface.cs
1 parent 1136635 commit 0a494c1

2 files changed

Lines changed: 10 additions & 13 deletions

File tree

src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterface.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1390,9 +1390,10 @@ public override void WriteProgress(Int64 sourceId, ProgressRecord record)
13901390
}
13911391
else
13921392
{
1393-
// lock (_instanceLock) is moved into HandleIncomingProgressRecord
1394-
// to exclude unneeded locks
1395-
HandleIncomingProgressRecord(sourceId, record);
1393+
lock (_instanceLock)
1394+
{
1395+
HandleIncomingProgressRecord(sourceId, record);
1396+
}
13961397
}
13971398
}
13981399
}

src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterfaceProgress.cs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,17 +90,13 @@ class ConsoleHostUserInterface : System.Management.Automation.Host.PSHostUserInt
9090
}
9191
}
9292

93-
if (progPaneUpdateFlag)
93+
if (progPaneUpdateFlag || record.RecordType == ProgressRecordType.Completed)
9494
{
95-
// Update the progress pane only when the timer set up the flag
96-
// as a result, we do not block WriteProgress and whole script
97-
// and eliminate unnecessary console locks and updates
98-
lock (_instanceLock)
99-
{
100-
_pendingProgress?.Update(sourceId, record);
101-
_progPane?.Show(_pendingProgress);
102-
progPaneUpdateFlag = false;
103-
}
95+
// Update the progress pane only when the timer set up the update flag or WriteProgress is completed.
96+
// As a result, we do not block WriteProgress and whole script and eliminate unnecessary console locks and updates.
97+
_pendingProgress.Update(sourceId, record);
98+
_progPane.Show(_pendingProgress);
99+
progPaneUpdateFlag = false;
104100
}
105101
}
106102

0 commit comments

Comments
 (0)