Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/System.Management.Automation/engine/hostifaces/PowerShell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4499,7 +4499,9 @@ private void CoreInvokeHelper<TInput, TOutput>(PSDataCollection<TInput> 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.
Expand All @@ -4512,7 +4514,9 @@ private void CoreInvokeHelper<TInput, TOutput>(PSDataCollection<TInput> 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)
{
Expand Down Expand Up @@ -4777,7 +4781,9 @@ private IAsyncResult CoreInvokeAsync<TInput, TOutput>(PSDataCollection<TInput> i
{
if (pool != null)
{
#if !UNIX
VerifyThreadSettings(settings, pool.ApartmentState, pool.ThreadOptions, pool.IsRemote);
#endif

pool.AssertPoolIsOpen();

Expand Down Expand Up @@ -4854,7 +4860,9 @@ private IAsyncResult CoreInvokeAsync<TInput, TOutput>(PSDataCollection<TInput> 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)
{
Expand Down Expand Up @@ -4904,6 +4912,8 @@ private IAsyncResult CoreInvokeAsync<TInput, TOutput>(PSDataCollection<TInput> i
return _invokeAsyncResult;
}

// Apartment thread state does not apply to non-Windows platforms.
#if !UNIX
/// <summary>
/// Verifies the settings for ThreadOptions and ApartmentState.
/// </summary>
Expand Down Expand Up @@ -4938,6 +4948,7 @@ private void VerifyThreadSettings(PSInvocationSettings settings, ApartmentState
}
}
}
#endif

/// <summary>
/// </summary>
Expand Down