Using AsyncCallback in Powershell
.net, powershell, powershell-3.0
Solution
Scriptblocks can be converted into most types of delegates by casting as follows.
$myCallback = [AsyncCallback]{
param( $asyncResult)
# callback code
if ($asyncResult.isCompleted) {
get-date
}
}
Problem
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?