0

I get this exception while running my program in this line:

DirectiveProcessingProvider _directiveProcessingProvider = new DirectiveProcessingProvider(rdeData.CollectorDB, rdeData.GridCollectorDB);
values[0] = _directiveProcessingProvider.ParseParamValue(values[0].ToString(), true);

While what it basically does is parsing a value from a dictionary. This dictuinary is being also loaded, maybe that's what cause the problem, but noting I've done helped that...

This is the dictionary load:

_collectorDB.SetItem((t.value as BaseControlProperties).Name, GetTextFromScreenInControlPosition(vco), true);

This common answer for solveing DIDN'T help:

this.Dispatcher.Invoke((Action)(() =>
{
    ...// your code here.
}));

Any idea why?

PS - Ive tried to add constant, just to check if getting the text from screen is the problem, and it isn't..

Any help will be appreciated.

MTZ
  • 109
  • 1
  • 12
  • For UI elements, it's always the main thread who owns them, and all operations affecting the UI (this includes changing properties which are bound to UI elements) must be done in the main thread. – derpirscher May 15 '16 at 07:19
  • Thanks @derpirscher! - Any idea of how to solve it? How can I avoid conflicts? And why the common option I've added above didn't help? – MTZ May 15 '16 at 07:28
  • 1
    Well, as I don't know your project structure, and which thread is calling what, and what values are bound to what UI elements, it's quite difficult to find the exact cause of your problem. You only give three lines of code without nearly any context. And you don't show, how you used the suggested answer. – derpirscher May 15 '16 at 07:36

0 Answers0