strange behaviour for the multi-threaded calculation in Excel 2007

  • Thread starter Thread starter Guillaume
  • Start date Start date
G

Guillaume

Hello world!

I observe a strange behaviour for the multi-threaded calculation in Excel
2007 with my XLL.
I have 2 functions A and B exported by the xll. They are registered as
threadsafe.
A is registered with R$.
B is registered with RR$

The function B depends on the result of the function A.
On a worksheet, I can declare:
- =A() in cell A1
- =B(A1) in cell A2

When I disable multi-threaded calculation, =A() is executed before =B(A1)
because B depends on the result of =A().
But, when I enable multi-threaded calculation, Excel runs A and B on
different threads. The function B failed with xlretUncalced when it called
xlCoerce. Excel launches again B after the execution of A. Why does excel
calculate B and A at the same time at the beginning?

Thanks for any suggestions.
 
Hi Guillaume,

I have not done many experiments on calculation sequence with multi-threaded
functions, but I think this is what is happening:

If you do not have multithreaded calculation enabled the order of
calculation is dictated by the previous calculation chain. After you have
completed a calculation A will be executed before B. But if you then go to
Manual Calculation and re-enter =A() in cell A1 and =B(a1) in cell A2 this
will place A2 at the top of the calculation chain so when you Press F9 the
calculation sequence will be
A2 (xlretUncalced)
A1
A2

So it is always possible that functions will be executed with uncalculated
arguments, even with multi-threading switched off.

When you switch on Multi-threading I would have expected the same behaviour:
so that if you do 2 successive recalculations the second recalculation would
always calculate in the correct order: but perhaps it behaves differently :
you can test by switching on Multi-threaded Calculation and doing
Ctrl/alt/F9 twice

Let me know what happens with the test!

Charles
___________________________________
The Excel Calculation Site
http://www.decisionmodels.com
 
Back
Top