diff --git a/src/System.Management.Automation/engine/remoting/fanin/WSManPlugin.cs b/src/System.Management.Automation/engine/remoting/fanin/WSManPlugin.cs index 1107219315b..be79b6a1253 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/WSManPlugin.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/WSManPlugin.cs @@ -473,15 +473,13 @@ internal void CloseShellOperation( return; } - SetThreadProperties(mgdShellSession.creationRequestDetails); // update the internal data store only if this is not receive operation. if (!context.isReceiveOperation) { DeleteFromActiveShellSessions(context.shellContext); } - string errorMsg = StringUtil.Format(RemotingErrorIdStrings.WSManPluginOperationClose); - System.Exception reasonForClose = new System.Exception(errorMsg); + System.Exception reasonForClose = new System.Exception(RemotingErrorIdStrings.WSManPluginOperationClose); mgdShellSession.CloseOperation(context, reasonForClose); } @@ -502,7 +500,7 @@ internal void CloseCommandOperation( //Dbg.Assert(false, "context.shellContext not matched"); return; } - SetThreadProperties(mgdShellSession.creationRequestDetails); + mgdShellSession.CloseCommandOperation(context); } diff --git a/src/System.Management.Automation/engine/remoting/fanin/WSManPluginShellSession.cs b/src/System.Management.Automation/engine/remoting/fanin/WSManPluginShellSession.cs index 3a30e708e81..73792fa7ffb 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/WSManPluginShellSession.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/WSManPluginShellSession.cs @@ -698,6 +698,8 @@ internal override void CloseOperation( } } + WSManPluginInstance.SetThreadProperties(creationRequestDetails); + bool isRcvOpShuttingDown = (context.isShuttingDown) && (context.isReceiveOperation); bool isRcvOp = context.isReceiveOperation; bool isShuttingDown = context.isShuttingDown; @@ -797,6 +799,8 @@ internal override void CloseOperation( } } + WSManPluginInstance.SetThreadProperties(creationRequestDetails); + bool isRcvOp = context.isReceiveOperation; // only one thread will be here. bool isRcvOpShuttingDown = (context.isShuttingDown) &&