So I want to create a way to run a powershell script asynchronously. The below code is what I have so far, but it doesn\'t seem to be async because it locks up the applicati
You are calling it asynchronously.
However, you are then defeating the purpose by synchronously waiting for the asynchronous operation to finish, by calling EndInvoke()
.
To actually run it asynchronously, you need to make your method asynchronous too.
You can do that by calling Task.Factory.FromAsync(...)
to get a Task<PSObject>
for the asynchronous operation, then using await
.