Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PowerShellCmdlet #4247

Merged
merged 1 commit into from Mar 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/PowerShell/CommonFiles/PowerShellCmdlet.cs
@@ -1,4 +1,4 @@
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// <copyright file="PowerShellCmdlet.cs" company="Microsoft Corporation">
// Copyright (c) Microsoft Corporation. Licensed under the MIT License.
// </copyright>
Expand Down Expand Up @@ -281,6 +281,7 @@ internal void Wait(Task runningTask, PowerShellCmdlet? writeCmdlet = null)
{
try
{
this.pwshThreadEdi = null;
this.pwshThreadAction();
}
catch (Exception e)
Expand Down Expand Up @@ -596,12 +597,17 @@ private void WaitMainThreadActionCompletion()
this.pwshThreadActionCompleted.WaitHandle,
});

if (this.pwshThreadEdi != null)
try
{
this.pwshThreadEdi.Throw();
if (this.pwshThreadEdi != null)
{
this.pwshThreadEdi.Throw();
}
}
finally
{
this.semaphore.Release();
}

this.semaphore.Release();
}

private class QueuedStream
Expand Down