Maybe simple question but how can I get the return object of a asynchronously System.Func?
Consider this:
private void Start(String a)
{
System.Func<String, objectA> callasync = delegate(String strA)
{
return bla(stra); // Which return a objectA
}
callasync.BeginInvoke(a, callback, null);
}
private void callback(IAsyncResult ar)
{
// Here I want the objectA but how ??
}
With callback function, I didn’t have the delegate signature. And of course, i can create a delegate in scope of the class but maybe is there a solution to read the return value in the callback function.
Thank.
When you use
BeginInvokeon a delegate, theIAsyncResultof passed to the callback will be an instance of theAsyncResultclass. From that you can get an instance of your delegate and callEndInvokeon it.