Page 1 of 1

ThreadException in CustomLinePointColoringAndShaping

Posted: Wed May 07, 2014 12:26 pm
by frank
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.

Re: ThreadException in CustomLinePointColoringAndShaping

Posted: Wed May 07, 2014 1:09 pm
by ArctionPasi
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;