I am using the following method to render a LiveChart into an image. However, I get the message that TempA is in another thread and I cannot access it. I understand this, the question is how do I get this resolved?
public static BitmapImage ChartToImage(LineSeries TempA, LineSeries TempB, LineSeries Level, List<string> Labels)
{
var thread = new Thread(() =>
{
CartesianChart cartesianChart = new CartesianChart();
.....
TempA.ScalesYAt = 0;
TempB.ScalesYAt = 0;
Level.ScalesYAt = 1;
.....
});
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
return bitmapImage;
}