Mar 20, 2014 at 9:37 AM
Edited Mar 20, 2014 at 9:38 AM
I have a function, which returns array. It works fine. But I also want to update this result by separate thread. How can I do it?
I have made a simple example, but it doesn't work. At least I don't see any changes in cell values:
// function.cpp - Rename this file and replace this description.
using namespace xll;
uintptr_t pthread = 0;
void __cdecl start(void*)
static long val = 100;
val += 100;
(*result)(0,0) = val;
(*result)(0,1) = val + 30;
ExcelX(xlSet, OPERX(0,0,1,2), *result);
static AddInX xai_function(
FunctionX(XLL_LPOPERX, _T("?xll_function"), _T("XLL.FUNCTION"))
.Arg(XLL_DOUBLEX, _T("Number"), _T("is a number"))
// .Arg(...) // add more args here
.FunctionHelp(_T("Description of what function does."))
.Documentation(_T("Optional documentation for function."))
result = new OPERX();
(*result)(0, 0) = x * 2;
(*result)(0, 1) = x * 3;
pthread = _beginthread(start, 0, 0);
Mar 20, 2014 at 10:16 AM
Computers don't operate by wishful thinking. You need to understand their basic principles before they do your bidding.
Your code leaks and can't possibly work asynchronously. Try looking at async.cpp in the test folder. If you understand what that does, you will probably be disappointed.