Using AsyncCallback in Powershell

Question:

I have to call a method on .NET object which is defined as

IAsyncResult BeginListMetrics( ListMetricsRequest listMetricsRequest,
AsyncCallback callback, Object state )

Is it possible to use a powershell function as a AsyncCallback delegate? How?

Answer:

Scriptblocks can be converted into most types of delegates by casting as follows.

Source:

Using AsyncCallback in Powershell by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply