Skip to content

Commit 8a00654

Browse files
authored
Fix PowerShellCmdlet (#4247)
1 parent 5b3bd95 commit 8a00654

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

src/PowerShell/CommonFiles/PowerShellCmdlet.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// -----------------------------------------------------------------------------
1+
// -----------------------------------------------------------------------------
22
// <copyright file="PowerShellCmdlet.cs" company="Microsoft Corporation">
33
// Copyright (c) Microsoft Corporation. Licensed under the MIT License.
44
// </copyright>
@@ -281,6 +281,7 @@ internal void Wait(Task runningTask, PowerShellCmdlet? writeCmdlet = null)
281281
{
282282
try
283283
{
284+
this.pwshThreadEdi = null;
284285
this.pwshThreadAction();
285286
}
286287
catch (Exception e)
@@ -596,12 +597,17 @@ private void WaitMainThreadActionCompletion()
596597
this.pwshThreadActionCompleted.WaitHandle,
597598
});
598599

599-
if (this.pwshThreadEdi != null)
600+
try
600601
{
601-
this.pwshThreadEdi.Throw();
602+
if (this.pwshThreadEdi != null)
603+
{
604+
this.pwshThreadEdi.Throw();
605+
}
606+
}
607+
finally
608+
{
609+
this.semaphore.Release();
602610
}
603-
604-
this.semaphore.Release();
605611
}
606612

607613
private class QueuedStream

0 commit comments

Comments
 (0)