Fix apartment thread state check on non-Windows platforms (#11301)

This commit is contained in:
Paul Higinbotham
2019-12-09 16:26:46 -08:00
committed by Dongbo Wang
parent 20a236b228
commit c232903bc0
@@ -4499,7 +4499,9 @@ namespace System.Management.Automation
{
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 @@ namespace System.Management.Automation
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 @@ namespace System.Management.Automation
{
if (pool != null)
{
#if !UNIX
VerifyThreadSettings(settings, pool.ApartmentState, pool.ThreadOptions, pool.IsRemote);
#endif
pool.AssertPoolIsOpen();
@@ -4854,7 +4860,9 @@ namespace System.Management.Automation
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 @@ namespace System.Management.Automation
return _invokeAsyncResult;
}
// Apartment thread state does not apply to non-Windows platforms.
#if !UNIX
/// <summary>
/// Verifies the settings for ThreadOptions and ApartmentState.
/// </summary>
@@ -4938,6 +4948,7 @@ namespace System.Management.Automation
}
}
}
#endif
/// <summary>
/// </summary>