Reputation: 3
Need Help in converting this to VB.NET
public void GetCustomers(Action<IEnumerable<Customer>> onSuccess, Action<Exception> onFail)
{
Manager.Customers.ExecuteAsync(op =>
{
if (op.CompletedSuccessfully)
{
if (onSuccess != null)
onSuccess(op.Results);
}
else
{
if (onFail != null)
{
op.MarkErrorAsHandled();
onFail(op.Error);
}
}
}
);
}
Upvotes: 0
Views: 323
Reputation: 1555
You can do in-line anonymous functions/subs with syntax like:
Manager.Customers.ExecuteAsync( Sub (op)
If op.CompletedSuccessfully Then
...
Else
...
EndIf
End Sub )
Sometimes things get really flakey when you use it inline, so when that happens I give the local sub/function a name:
Dim SomeFun as Action(Of OpType) = Sub (op)
...
End Sub
This works well because you can still close over your lexical environment.
This is all from memory - I don't have VS at home (and I try not to troll SO at work). In particular, I'm not sure I have my closing paren in the right place.
MSDN Reference
Upvotes: 1