Use Powershell’s BeginInvoke() and EndInvoke() in async way

Question:

Is there a way to use Powershell’s BeginInvoke() and EndInvoke() in a real async way. That’s, I just call BeginInvoke() and then forget instead of using EndInvoke to wait for the return or result. I like EndInvoke to be a callback function called automatically when BeginInvoke() finishes.
The example on MSDN is actually a sync one.

How can I use BeginInvoke() and EndInvoke() in a real async way? Thanks.

Answer:

You should probably use BeginInvoke overload with AsyncCallback argument.

Source:

Use Powershell’s BeginInvoke() and EndInvoke() in async way by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply