I really like the Async Registration setup for using async functions, but there a few things I don't understand about the ExcelRegistration. It appears that the order of the ExcelRegistion statement needs to be different for registering RTD or Native async functions.
Here is my example that works for registering RTD async functions and what I think the wrapped functions look like. In this case all three async functions work as expected with the dnaDelayedTaskHello working as RTD based async function, and the postAsyncReturnConfig works for both the dnaDelayedTaskHello and dnaRtdWrapped functions, returning #GETTING_DATA while processing.
using System;
using System.Linq.Expressions;
using System.Threading.Tasks;
using ExcelDna.Integration;
using ExcelDna.Registration;
using ExcelDna.Registration.Utils;
using ExcelDna.IntelliSense;
namespace ExcelDnaRegistration
{
public class AddIn : IExcelAddIn
{
public void AutoOpen()
{
// Register Funtion settings
var postAsyncReturnConfig = GetPostAsyncReturnConversionConfig();
ExcelRegistration.GetExcelFunctions()
.ProcessAsyncRegistrations(nativeAsyncIfAvailable: false)
.ProcessParameterConversions(postAsyncReturnConfig)
.RegisterFunctions();
// Intellinse Sense
IntelliSenseServer.Register();
}
public void AutoClose()
{
}
static ParameterConversionConfiguration GetPostAsyncReturnConversionConfig()
{
// This conversion replaces the default #N/A return value of async functions with the #GETTING_DATA value.
var rval = ExcelError.ExcelErrorGettingData;
return new ParameterConversionConfiguration()
.AddReturnConversion((type, customAttributes) => type != typeof(object) ? null : ((Expression<Func<object, object>>)
((object returnValue) => returnValue.Equals(ExcelError.ExcelErrorNA) ? rval : returnValue)));
}
}
public class Functions
{