You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This behavior changed between PowerShell versions 5.0 and 5.1. The change was to make PowerShell class method script blocks bound to the runspace in which they were created. If a class instance method is run from within a different runspace then it gets "marshaled" back to the original runspace (via engine events). The result is that if a single class instance is shared among multiple runspaces (e.g., a runspace pool) with the intention to execute instance methods concurrently, the methods run serially instead.
I don't know why this changed between 5.0 and 5.1 but it looks to be by design. @vors can you please comment?
This behavior changed between PowerShell versions 5.0 and 5.1. The change was to make PowerShell class method script blocks bound to the runspace in which they were created. If a class instance method is run from within a different runspace then it gets "marshaled" back to the original runspace (via engine events). The result is that if a single class instance is shared among multiple runspaces (e.g., a runspace pool) with the intention to execute instance methods concurrently, the methods run serially instead.
I don't know why this changed between 5.0 and 5.1 but it looks to be by design. @vors can you please comment?
Repro steps:
Expected:
5 concurrently running 1 second loops (with sleep) should take about 1 second to run.
Actual Result:
It takes about 5 seconds to run indicating that the concurrent scripts are running serially.