Your implementation will run async on a different thread, but there will be a wrapper that (for now) must not be marked as IsThreadSafe, and this wrapper will run on the main thread.
So you might have:
```
static async Task<object[,]> MyFunctionImpl(string arg1, int arg2) { ... real implementation here which will run on threadpool thread ... }
[ExcelFunction("My async function", IsThreadSafe=false)]
public static object MyFunction(string arg1, int arg2)
{
// Gather call information
var functionName = nameof(MyFunction);
var parameters = new object[] { arg1, arg2 };
// Call magic wrapper that will internally call ExcelAsyncUtil.Observer etc. - everything here is still running on the main thread
return AsyncTaskUtil.RunTask(functionName, parameters, () => MyFunctionImpl(arg1, arg2));
}
```
You can get the AsyncTaskUtil helper by installing the ExcelDna.Registration package, or by grabbing the little bit of code you need from here:
and you'll also need these helpers:
-Govert