Thanks. I guess my real question is...how can I call an async function and within that function access MS Excel COM objects (i.e. current worksheet, ranges, etc.)? Or is that not possible? In all my other questions about async, I've been able to call COM stuff within `QueueAsMacro` context and any async stuff, I launched in separate context that maybe or may not just continue this path of launch nested QueueAsMacro and additional 'async' contexts.
But this last feature I need to support unfortunately I can't use C API because of
this issue.
During .NET Core Debug Session in VS Code:
ExcelDna.Integration.XlCall.Excel( ExcelDna.Integration.XlCall.xlfEvaluate, "=IF(BTRContains(\"terry\", \"er\"),1,2)" )
1
ExcelDna.Integration.XlCall.Excel( ExcelDna.Integration.XlCall.xlfEvaluate, "=IF(BTRContains(\"terry\", \"er\"),IF(BTRContains(\"terry\", \"er\"),1,2),3)" )
ExcelErrorName
However, the async code flow jumps back and forth between needing access to 'excel info' and doing 'async work' too often to try and follow the aforementioned pattern. Worse off is that this code is in a helper assembly that doesn't know anything about the Excel UI thread context issue. Using COM, it was as simple as making a hidden worksheet and doing this:
wsEvaluate.Range[ "A1" ].Formula = formula;
var value = wsEvaluate.Range[ "A1" ].Value;
Struggling to think of a possible work around I could pull off :(