Hi Dojo,
I'm using below code to simulate Power Consumption for demo purposes.
After some time I noticed in the trend graph that huge spikes were available.
By adding logging I noticed that a correct value is received when the system is using Culture Info Invariant Culture.
2021/10/22 05:00:59.771|SLManagedScripting.exe|ManagedInterop|CRU|-1|191|property value: 9.52 | expected consumption: 9.52 | expected consumption (W): 396.666666666667 | random value: 0.72 | power consumption: 285.6 | Culture Info: Invariant Language (Invariant Country) | thread culture: Invariant Language (Invariant Country) | System culture: Invariant Language (Invariant Country)
When it goes wrong the system is using Culture Info Dutch (Belgium)
2021/10/22 05:21:20.791|SLManagedScripting.exe|ManagedInterop|CRU|-1|174|property value: 9.52 | expected consumption: 952 | expected consumption (W): 39666,6666666667 | random value: 0,78 | power consumption: 30940 | Culture Info: Dutch (Belgium) | thread culture: Dutch (Belgium) | System culture: Dutch (Belgium)
My question is how it is possible that the Culture Info changes? Is this an issue? Is this DataMiner related? Is this Windows related?
PS: My code is fixed by specifying the Culture Info.
CurrentCulture is the culture of the thread, which is normally the culture of the OS, unless overridden. I suppose some other QAction sets the Thread culture to InvariantCulture. Depending on the order of execution, it would sometimes be the OS culture (Dutch Belgium), or InviarantCulture.
I advise to use InvariantCulture in your code, so it's always using the same culture.
It doesn’t need to be your QAction. Any QAction that is executed in that same thread could have changed the culture.
Does that mean that different elements/protocols are using the same thread? I thought that every element had his own thread.
These threads are indeed shared.
Hi Lander, this is the only QAction executed on a regular base (10 seconds) and nothing else is setting the Culture Info in that QAction. I also had a look in the information events and no external sets were done. I know that specifying Invariant Culture will fix this, but this seems to be an issue that the Culture Info suddenly changes.