Hi Simon,
In principle the Registration extension does something like this to your IObservable function:
* static IObservable<string> myFunc(string name, int msDelay) {...}
*
* is rewritten to
*
* static object myFunc(string name, int msDelay)
* {
* return ExcelAsyncUtil.Observe<string>( // obsMethod
* "myFunc", // name
* new object[] {(object)name, (object)msDelay}, // paramsArrayExp
* () => myFunc(name, msDelay)); // innerLambda
* }
I’ll call the original myFunc the ‘inner’ function and the second version the ‘wrapper’ function.
Then you have the scenario where
Now pressing F2 & Enter on the cell recalculates the wrapper function, but looks exactly like the calculation triggered by the observable update.
So the RTD topic is found and the value returned directly, without running the inner function again.
If the parameters do change between calls, the ExcelAsyncUtil.Observe will notice that there is no matching RTD topic for the name and parameters, and will set up a new topic, and call the inner function to get the observable to hook up.
By not getting the RTD value for the old topic when the cell is recalculated, Excel understands that the old topic must be disconnected, and Excel -DNA ensures that Dispose is called on the IDisposable returned from your observable’s Subscribe method.
Similar if the formula is deleted.
I hope that explains what you’re seeing as being the ‘expected’ behaviour.
I think this is what you are asking about.
Thus using F2 is not a good way to explicitly rigger a reset of the observable (and causing the inner function to be called again).
Inside the wrapper function we can’t distinguish the F2 & Enter recalculation from the RTD / observable update causing a calculation of the wrapper.
You could try to set some internal flags and track the timing, but that will probably be hard to make reliable, as the observable-triggered recalc can happen much later if Excel has been busy.
There are some options I can think of:
-Govert
--
You received this message because you are subscribed to the Google Groups "Excel-DNA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to exceldna+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/exceldna/4c8aa77b-8736-41e4-9978-ce7da3dd2e2dn%40googlegroups.com.