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.
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.