Excel-DNA support two types of async functions:
* RTD-base async functions.
For the RTD-base async functions, I have made an async batch wrapper that might be worth looking into. The sample code is here https://github.com/Excel-DNA/Samples/blob/master/Misc/AsyncBatchSample.cs:
* Native Excel async functions, which you seem to be using
For the native async functions you are right that Excel-DNA has no easy support for setting multiple results at once. But it might be as easy as adding a call like this:
public static bool SetResults(object[] asyncHandles, object[] results)
{
XlCall.XlReturn callReturn = XlCall.TryExcel(XlCall.xlAsyncReturn, out object _, asyncHandles, results);
}
Let us know if you give it a try.
-Govert
--
You received this message because you are subscribed to the Google Groups "Excel-DNA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to exceldna+u...@googlegroups.com.
To post to this group, send email to exce...@googlegroups.com.
Visit this group at https://groups.google.com/group/exceldna.
For more options, visit https://groups.google.com/d/optout.
It might work if you don’t change the data types yourself, but let the built-in marshalling build the right XLopers.
Would you be able to try the snippet I sent?
If that does not work, it would help if you could post as a GitHub Gist or elsewhere a bit of code I can run as a test to sort it out.
-Govert
--
Govert, you were right! I commented out the code that I added to TryExcelImp12() and tried passing in the array of ExcelAsyncHandle's rather than the array of IntPtr's to XlCall.TryExcel and it worked! Thanks so much for your help! For future reference, it's just this call:
Yes - please try with sending the ExcelAsyncHandles in the object[] array - the marshalling processes these differently.-Govert
On Tue, 23 Apr 2019, 18:41 Hughes Hilton, <fhughe...@gmail.com> wrote:
Yeah I actually did try the exact thing that you sent. I was just saying that in order to do that I had to expose the IntPtr Handle on the ExcelAsyncHandle so I could create an array of them to pass in. Unless you are suggesting that I ought to just pass in an array of ExcelAsyncHandle instead? I can try that as well. Also, here is the code I added to XlCallImp.TryExcelImp12 in order to try and make xlAsyncReturn work according to the Excel doc (which throws an exception):--if (xlFunction == (16 | 0x4000) && parameters.Length == 2) // xlAsyncReturn{// For xlAsyncReturn, ppOperParameters should be the array of handles and pResultOper// should be the array of values.XlOper12** ppOperParameters = (XlOper12**)paramMarshaler.MarshalManagedToNative(parameters[0]);XlOper12** ppResultOper = (XlOper12**)paramMarshaler.MarshalManagedToNative(parameters[1]);xlReturn = Excel12v(xlFunction, parameters.Length, ppOperParameters, *ppResultOper);}Thank you so much for looking into this! I will also test out passing the array of ExcelAsyncHandle directly to see if the marshaller handles that correctly.Regards,Hughes
You received this message because you are subscribed to the Google Groups "Excel-DNA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to exce...@googlegroups.com.