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?
Scriptblocks can be converted into most types of delegates by casting as follows.
$myCallback = [AsyncCallback]{
param( $asyncResult)
# callback code
if ($asyncResult.isCompleted) {
get-date
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With