Click here to Skip to main content
15,881,938 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have several problems when i have a very large number of point on my series in my chart area, the problem is my GUI block, but chart point are ploting perfectly, my progress bar and my timer (elapsed) stop running, but qhen a i resize my form to small resolution, it work perfectly.

(sorry my english first)


I do only this, i dont use graph, add points directly to the seria asigned to the chart

asing serie
C#
chart1.Series.Add(Serie[(int)showfactor]);


adding point
C#
Serie[0].Points.AddXY(_CoordenadaX,_CoordenadaY / 1000);


show point
C#
chart1.Series.SuspendUpdates();
ConfigExperimentos[working].NuevoDato(nuevodato);
chart1.Series.ResumeUpdates();


advice that is a real time app.


C#
  private void serialPort_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e){
while (serialPort.BytesToRead >= 14)
    {
       for (int i = 0; i < 14; i++)
         {
           buffer[i] = (byte)serialPort.ReadByte();
         }
       if (buffer[13] == (byte)'F')
         {
           this.BeginInvoke(new InvokeDelegate(() =>
           {
             this.Invoke(new EventHandler(DatoRecibido));//this is a model class
            }));
         }
         else
         {
            while ((charend != (byte)'F') && (serialPort.BytesToRead != 0))
                    charend = (byte)serialPort.ReadByte();
         }
    }
}
Posted
Updated 7-Oct-15 0:03am
v5
Comments
phil.o 7-Oct-15 5:28am    
Please show some relevant parts of your code (for example, and especially, the code where you are assigning your data-serie to the chart, and the code responsible for the chart-drawing).
Please add the code TO YOUR QUESTION (use the improve button), not in a comment; comments are not meant to hold code-blocks. Thank you.

I'm not really sure, but I have the impression that you are adding the points one by one.

Maybe you could try to add them all at a time, enclosing the add operation between chart1.Series.SuspendUpdates(); and chart1.Series.ResumeUpdates();.
 
Share this answer
 
Comments
Jesús Álvarez 7-Oct-15 6:59am    
I do that
The problem was that the datareceived event and this.Invoke("other event"), block I because the read operation and paint operation (in chart), fill all the task queue and the UIthread never keep alive between that, result the GUI dont refresh until datareceiver is working.

I need to reestructure the code with producer-consumer pattern and async methods, to ensure that i call refresh the GUI and notify the UItreahd io am doing that.

Thanks.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900