Reputation: 35
When i call a async function from third party library then i found that the function need to pass the callback.
the function is
Library.getResult(object options, Action<library.libresult<dataCollection>> callback
can someone tell me how i can pass callback to this function in silverlight.
thanks
Upvotes: 2
Views: 224
Reputation: 700152
You use a delegate for method that accepts the result. You can for example use a lambda expression to create that:
Library.getResult(options, result => {
// code here runs when the result arrives
});
You can also declare a named method:
private void HandleResult(library.libresult<dataCollection> result) {
//...
}
Then just use its name in the call, which will automatically create a delegate for it:
Library.getResult(options, HandleResult);
Upvotes: 3
Reputation: 1062520
An Action<library.libresult<dataCollection>>
is a method that takes a library.libresult<dataCollection>
, so the following should work:
Library.getResult(options, result => {
// do something with result
});
Here, result
will be the library.libresult<dataCollection>
it gives you back. Presumably (but not for certain) this is async, so you may need to consider the threading issues etc.
Upvotes: 2