Open pw182162 opened 3 years ago
@pw182162 , the callback function should execute only once, every time something changes in the received message, such as data, column, parameter, etc. What action(s) are you performing in the VA report that is triggering those changes and therefore sending different messages to the DDC object? Also, remember that VA queries are performed asynchronously, so if the final value is a result of multiple calculations (specially those involving parameters), it may be the case that the calculated value assumes intermediate results until all branches are fully calculated, and this could trigger multiple messages, but the last one should be the correct one.
Please, ignore my previous message. After re-reading your message I think I know what's going on. When the popup window (hidden page) opens, it displays the old information because this had been cached last time the window was opened. The fact that the window is reloaded sends a message to the DDC with the current (old) value. When the new value is refreshed a new message is sent to the DDC. I don't know if there is a better way of doing it, but apparently in your particular case you will always get two messages, where only the second one is the correct one. Due to the asynchronous nature of this processing, we would need to try a combination of semaphore and timer in your callback function to make sure the first one is ignored if a second message arrives in a timely fashion.
@rluppi, thank you for confirming this. I figured out how to do a workaround. It works for me this way:
Hi! We have an issue in the VA-PopUp-Window (hidden Report). The setOnDataReceivedCallback is executed twice. First call with the data from the previous execution and the second with the new data. Unfortunately it is not deterministic which one will be executed first. Most of the time the "order" is correct, but not always. So it's like 10% chance that you get a wrong data. Any Idea how to workaround this issue?