diff --git a/src/System.Management.Automation/engine/hostifaces/PowerShell.cs b/src/System.Management.Automation/engine/hostifaces/PowerShell.cs index 54ddd650e37..d1b26a1e111 100644 --- a/src/System.Management.Automation/engine/hostifaces/PowerShell.cs +++ b/src/System.Management.Automation/engine/hostifaces/PowerShell.cs @@ -4499,7 +4499,9 @@ private void CoreInvokeHelper(PSDataCollection input, P { if (pool != null) { +#if !UNIX VerifyThreadSettings(settings, pool.ApartmentState, pool.ThreadOptions, false); +#endif // getting the runspace asynchronously so that Stop can be supported from a different // thread. @@ -4512,7 +4514,9 @@ private void CoreInvokeHelper(PSDataCollection input, P rsToUse = _rsConnection as Runspace; if (rsToUse != null) { +#if !UNIX VerifyThreadSettings(settings, rsToUse.ApartmentState, rsToUse.ThreadOptions, false); +#endif if (rsToUse.RunspaceStateInfo.State != RunspaceState.Opened) { @@ -4777,7 +4781,9 @@ private IAsyncResult CoreInvokeAsync(PSDataCollection i { if (pool != null) { +#if !UNIX VerifyThreadSettings(settings, pool.ApartmentState, pool.ThreadOptions, pool.IsRemote); +#endif pool.AssertPoolIsOpen(); @@ -4854,7 +4860,9 @@ private IAsyncResult CoreInvokeAsync(PSDataCollection i LocalRunspace rs = _rsConnection as LocalRunspace; if (rs != null) { +#if !UNIX VerifyThreadSettings(settings, rs.ApartmentState, rs.ThreadOptions, false); +#endif if (rs.RunspaceStateInfo.State != RunspaceState.Opened) { @@ -4904,6 +4912,8 @@ private IAsyncResult CoreInvokeAsync(PSDataCollection i return _invokeAsyncResult; } + // Apartment thread state does not apply to non-Windows platforms. +#if !UNIX /// /// Verifies the settings for ThreadOptions and ApartmentState. /// @@ -4938,6 +4948,7 @@ private void VerifyThreadSettings(PSInvocationSettings settings, ApartmentState } } } +#endif /// ///