Skip to content

Reuse of Host for CreateRunspace OK? #2

@JustinGrote

Description

@JustinGrote

Hi @PaulHigin,

_runspace = RunspaceFactory.CreateRunspace(
connectionInfo: _connectionInfo,
host: Host,
typeTable: TypeTable.LoadDefaultTypeFiles(),
applicationArguments: null,
name: Name);

Here in the createrunspace the cmdlet host is used, however https://learn.microsoft.com/en-us/dotnet/api/system.management.automation.host.pshost?view=powershellsdk-7.2.0#remarks says There is a 1:1 relationship between the instance of the host class and the Runspace instance to which it is passed. In other words, it is not legal to pass the same instance of the host class to more than one call to CreateRunspace. (It is perfectly legal to call CreateRunspace more than once, as long as each call is supplied a unique instance of the host class.)

If you make multiple connections, doesn't this result in the same host instance being used for each remote runspace, thus violating the 1:1 relationship?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions