I have an application that used multiple GUI threads for performance reasons. I noticed that the XAMDataChart will crash if I load charts on different threads. It seems to have to do with setting the CrosshairLineStyle on only some of the charts. I have a application that demonstrates this. To reproduce launch the application and click the button that says "other". a window should open (this window is not on the main thread). Then click the button that says "main". The app will crash with an error about accessing a resource from the wrong thread.
The fix for development issue 212110 is available in the latest service release which can be downloaded from the My Keys and Downloads page.
Thanks, I had already done that workaround and it works just fine.
Hi John,
The issue actually has to do with the default Crosshair line style that the XamDataChart uses. When you create the first XamDataChart, the Styles contained within the chart assembly are instantiated. For the crosshair line style, the default style is using a special object called a SafeSetter that we have created to allow handling of drop shadows in a particular way. This object is being instantiated as well in the thread that created the first XamDataChart which means that this thread now owns that resource. When creating a second XamDataChart in a different thread than the first one, the default crosshair style is actually being used and this causes the thread to try and access parts of that SafeSetter and crashes.
This is most likely a bug with the SafeSetter so I have logged a development issue for this. The development issue ID is 212110. I have also created a private support ticket for you so that you can track it. The case number is CAS-168458-X7K9X7 and you can view it here.
As a workaround I recommend providing your own crosshair style for each XamDataChart. Providing your own style gets around the usage of the SafeSetter which avoids the cross thread access issue. I attached a sample demonstrating this.