0
내가 (툴킷 차트 WPF 사용하여) 차트를 만들려면이 코드를 작성 실행되지 않을 수 있습니다하지만 난이 오류가 발생,컬렉션이 수정되었습니다. 열거 작업이
private void Window_Loaded(object sender, RoutedEventArgs e)
{
LoadLineChartData2();
}
private void LoadLineChartData2()
{
time= new Timer(10);
time.Elapsed += new ElapsedEventHandler(time_Elapsed);
time.Start();
}
Timer time;
List<KeyValuePair<double, int>> list = new List<KeyValuePair<double, int>>();
int index = 0;
void time_Elapsed(object sender, ElapsedEventArgs e)
{
list.Add(new KeyValuePair<double,int>(1.0/int.Parse(e.SignalTime.Second.ToString()),index++));
this.Dispatcher.Invoke(new Action(()=> {
((System.Windows.Controls.DataVisualization.Charting.LineSeries)mcChart.Series[0]).ItemsSource = list;
if (index>200)
{
time.Stop();
}
}));
}
erorr : 컬렉션이 수정; 열거 연산이 실행되지 않을 수 있습니다.
오류 란 무엇이며 어떻게 점을 동적으로 추가 할 수 있습니까 ??
"C# Collection was modified"검색 - 여러 번 전에 물어보기. 먼저 검색해보십시오. –
예 : 첫 번째 히트 (그리고 거기에로드가) : http://stackoverflow.com/questions/604831/collection-was-modified-enumeration-operation-may-not-execute –