{"action":"created","issue":{"url":"https://api.github.com/repos/PowerShell/PowerShell/issues/6908","repository_url":"https://api.github.com/repos/PowerShell/PowerShell","labels_url":"https://api.github.com/repos/PowerShell/PowerShell/issues/6908/labels{/name}","comments_url":"https://api.github.com/repos/PowerShell/PowerShell/issues/6908/comments","events_url":"https://api.github.com/repos/PowerShell/PowerShell/issues/6908/events","html_url":"https://github.com/PowerShell/PowerShell/issues/6908","id":324890830,"node_id":"MDU6SXNzdWUzMjQ4OTA4MzA=","number":6908,"title":"Discussion: Defaults for Thread.ApartmentState","user":{"login":"bergmeister","id":9250262,"node_id":"MDQ6VXNlcjkyNTAyNjI=","avatar_url":"https://avatars0.githubusercontent.com/u/9250262?v=4","gravatar_id":"","url":"https://api.github.com/users/bergmeister","html_url":"https://github.com/bergmeister","followers_url":"https://api.github.com/users/bergmeister/followers","following_url":"https://api.github.com/users/bergmeister/following{/other_user}","gists_url":"https://api.github.com/users/bergmeister/gists{/gist_id}","starred_url":"https://api.github.com/users/bergmeister/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bergmeister/subscriptions","organizations_url":"https://api.github.com/users/bergmeister/orgs","repos_url":"https://api.github.com/users/bergmeister/repos","events_url":"https://api.github.com/users/bergmeister/events{/privacy}","received_events_url":"https://api.github.com/users/bergmeister/received_events","type":"User","site_admin":false},"labels":[{"id":311043053,"node_id":"MDU6TGFiZWwzMTEwNDMwNTM=","url":"https://api.github.com/repos/PowerShell/PowerShell/labels/Issue-Question","name":"Issue-Question","color":"fc2929","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2018-05-21T12:01:02Z","updated_at":"2018-06-30T00:11:07Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"This is to discuss and potentially document current behaviour (that is inconsistent with Windows PowerShell). Maybe some porting work was forgotten since the APIs were initially not available in .Net Core 1.\r\n\r\nWhen creating a new PowerShell instance using `[Management.Automation.PowerShell]::Create()` (or when creating a new runspace using `[runspacefactory]::CreateRunspace()`), then PowerShell Core and Windows PowerShell are both in `MTA` mode. This seems to be reasonable.\r\n\r\nWhen being in the shell of `PowerShell Core`, the default ApartmentState is also `MTA`, which seems OK as well at first.\r\nHowever, Windows PowerShell is in `STA` mode by default and `powershell.exe` even has an `MTA` and `STA` switch, which PowerShell Core does not have.\r\n\r\nMy questions:\r\n\r\n- Why was `STA` chosen to be the default when being in a shell or ConsoleHost of Windows PowerShell? If there was a reason, we should reconsider it for PowerShell Core. I should add though that this inconsistency could lead to a situation that is difficult to debug (we had a case where execution in the shell was fine but when using our PowerShell runner that uses the PowerShell APIs, we were experiencing threading issues and scratching our heads for some time what the reason could be until we found out about the inconsistency in Windows PowerShell)\r\n- Does `pwsh` need an `STA` command line option? In our case we can workaround it by setting it ourselves by setting it in the `InitialSessionState` that we then pass to `PowerShell.Create()`"},"comment":{"url":"https://api.github.com/repos/PowerShell/PowerShell/issues/comments/401502672","html_url":"https://github.com/PowerShell/PowerShell/issues/6908#issuecomment-401502672","issue_url":"https://api.github.com/repos/PowerShell/PowerShell/issues/6908","id":401502672,"node_id":"MDEyOklzc3VlQ29tbWVudDQwMTUwMjY3Mg==","user":{"login":"TravisEz13","id":10873629,"node_id":"MDQ6VXNlcjEwODczNjI5","avatar_url":"https://avatars1.githubusercontent.com/u/10873629?v=4","gravatar_id":"","url":"https://api.github.com/users/TravisEz13","html_url":"https://github.com/TravisEz13","followers_url":"https://api.github.com/users/TravisEz13/followers","following_url":"https://api.github.com/users/TravisEz13/following{/other_user}","gists_url":"https://api.github.com/users/TravisEz13/gists{/gist_id}","starred_url":"https://api.github.com/users/TravisEz13/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TravisEz13/subscriptions","organizations_url":"https://api.github.com/users/TravisEz13/orgs","repos_url":"https://api.github.com/users/TravisEz13/repos","events_url":"https://api.github.com/users/TravisEz13/events{/privacy}","received_events_url":"https://api.github.com/users/TravisEz13/received_events","type":"User","site_admin":false},"created_at":"2018-06-30T00:11:07Z","updated_at":"2018-06-30T00:11:07Z","author_association":"MEMBER","body":"Is this answered?  Can I close it?\r\n"}}
{"actor":{"display_login":"TravisEz13"}}