I am calling the timer every 100 milliseconds and running the UIThread in the timer function. I am getting the value of SpeedKmh from a server program by using another thread. The values are plotted on the chart but after sometime the app crashes. It this because the memory of the app is getting filled? How do I fix this problem?
Here is the code -
static FastLineSeries SpeedLine;
static ObservableCollection speedData = new ObservableCollection();
RunOnUiThread(() =>
{
count++;
// Speed chart plotting Speed speed = new Speed() { Speed_xAxis = count, SpeedData = SpeedKmh }; if (speed != null) { speedData.Add(speed); } SpeedLine = new FastLineSeries() { ItemsSource = speedData, XBindingPath = "Speed_xAxis", YBindingPath = "SpeedData" }; SpeedLine.Color = Color.Yellow; speedChart.Series.Add(SpeedLine);
}
Answers
There are no exceptions thrown. The app runs for a minute or so and then starts becoming slow and crashes.