This project has moved. For the latest updates, please go here.
1

Closed

ExcelRtdObserver OnNext misses updates

description

Hi,

We've found a bug with the ExcelRtdObserver code. It seems that when OnNext is called twice in quick succession the second update will sometimes be ignored.

Looking at the code I believe this is because ExcelDNA is using the current datetime, converted to an OLE automation date, as a proxy for the "new" topic value. Unfortunately DateTime.UtcNow.ToOADate will truncate to the nearest millisecond (see http://stackoverflow.com/questions/3724355/net-datetime-different-resolution-when-converting-to-and-from-oadate) so calling it twice within the same millisecond doesn't have the desired effect.

I have experimented with using a simple incrementing counter instead (and using the same counter in ConnectData) and that seems to resolve the problem.

Thanks,

Ben
Closed Sep 30, 2015 at 10:34 PM by govert
Fixed bug

comments

govert wrote Apr 22, 2015 at 7:43 PM

Hi Ben,

Thank you for reporting this!
I agree it can go wrong, though it would be quite rare - Excel would have to do the RTD callback in the millisecond between your calls.

Note that the RTD semantics does not imply that every update would go through to Excel. Under correct operation there many be any number of OnNext() calls that never update the cell. The requirement is just that the cell update eventually to the last OnNext() value.

I'll have a look and report back.

-Govert

govert wrote Apr 22, 2015 at 10:16 PM

If I understand things right, we don't have to set a new value in OnNext() at all. We can just call _topic.UpdateNotify(), which will ensure that the topic is dirty, that Excel's UpdateNotify is called, and that the topic is added to the RefreshData list.

Do you have any reason to think Excel cares about whether the values returned in RefreshData(...) have changed or not?

-Govert

govert wrote Apr 23, 2015 at 12:26 AM

It looks OK with just the UpdateNotify() in my quick test (and avoids some issues we might have a counter and how the topic is initialized).

I've pushed the update GitHub: https://github.com/Excel-DNA/ExcelDna
Please let me know if you're able to try it that way.

-Govert

sbyse wrote Apr 24, 2015 at 8:26 AM

Thanks a lot for the quick response,

That looks good to me, seems like a more straighforward way of solving the problem.

I'll let you know if we have any more issues,

Best Regards,

Ben