Hi,
after upgrading to Version 6.0.1 I get an System.InvalidOperationException in an CustomLinePointColoringAndShaping-Implementation. The line
_chart.ViewXY.YAxes[0].CoordToValue(coords.Y, out yValue);
causes "The calling thread cannot access this object because a different thread owns it." In LC 5.5 it worked without any problems.
ThreadException in CustomLinePointColoringAndShaping
Moderator: Queue Moderators
- ArctionPasi
- Posts: 1367
- Joined: Tue Mar 26, 2013 10:57 pm
- Location: Finland
- Contact:
Re: ThreadException in CustomLinePointColoringAndShaping
Hello.
You are are probably accessing dependency preperties, like ViewXY or X axis in the event handler. DPs work only in UI thread. LC uses multithreading by default for rendering of the line series, and the CustomLinePointColoringAndShapingHandler event fires from a threadpool task. That causes the problem. The event handler needs to execute right there, and it can't be queued in the UI thread by Dispatcher.Invoke.
The solution is to disable multithreading from that chart. Set chart.ChartRenderOptions.MultiCoreProcessing = MultiCoreProcessing.Off;
You are are probably accessing dependency preperties, like ViewXY or X axis in the event handler. DPs work only in UI thread. LC uses multithreading by default for rendering of the line series, and the CustomLinePointColoringAndShapingHandler event fires from a threadpool task. That causes the problem. The event handler needs to execute right there, and it can't be queued in the UI thread by Dispatcher.Invoke.
The solution is to disable multithreading from that chart. Set chart.ChartRenderOptions.MultiCoreProcessing = MultiCoreProcessing.Off;
LightningChart Support Team, PT