It is necessary to do so that you can see the construction of the object in the Chart, but the program did not hang. There is a code without Invoke arranges speed, but the form hangs up.

 for (int i = 0; i < vectorDictionary.Count; i++) { List<PointF> l = vectorDictionary[i]; for (int j = 0; j < l.Count; j++) { chart1.Series[i+1].Points.AddXY(l[j].X, l[j].Y); if(j%7==0) chart1.Refresh(); } } 

With Invoke. Slow speed, as many points to build

  await Task.Run(() => { for (int i = 0; i < vectorDictionary.Count; i++) { List<PointF> l = vectorDictionary[i]; for (int j = 0; j < l.Count; j++) { chart1.Invoke(new MethodInvoker(() => { chart1.Series[i+1].Points.AddXY(l[j].X, l[j].Y); })); } } }); 

How to achieve a visible construction without a form hanging?

  • Invok to a group of points. let's say 100 points. Create a temporary array of points, write a function that accepts it and adds points to the graph, and call the function itself in Invoke - Alexey Obukhov
  • @ Alexey Obukhov has done it so far, maybe there is some more correct option - Sonfire
  • You can try to make chart1.SuspendLayout () before adding points, and then chart1.ResumeLayout (). Unless of course the schedule is a successor to Control. - Alexey Obukhov

0