Skip to content

Impossible to open Runspace using OpenAsync and return after initial session state is loaded #8012

@KirkMunro

Description

@KirkMunro

If you create a Runspace and want to use OpenAsync to open that runspace asynchronously, while not continuing on to other code until the runspace opened and initialized, it's not possible to do so. If instead of invoking OpenAsync, you invoke Open, that API won't return until after the runspace is both open and initialized with the initial session state.

Steps to reproduce

https://stackoverflow.com/questions/17712240/why-does-runspace-openasync-ignore-initialsessionstate

Expected behavior

There must be a way to use OpenAsync with an event handler that triggers TaskCompletionSource<>.TrySetResult once the initialization is complete.

Actual behavior

This is not possible today.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Committee-ReviewedPS-Committee has reviewed this and made a decisionIssue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-No ActivityIssue has had no activity for 6 months or moreWG-Enginecore PowerShell engine, interpreter, and runtime

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions