This project is read-only.

time-lag

Aug 1, 2013 at 3:00 PM
Please help,
receive data from the com port and draw them in real time.
after 3 minutes with 5000 data points component terribly lag

wpf
private void Window_Loaded(object sender, RoutedEventArgs e)
    {
        source1 = new ObservableDataSource<Point>();
        source2 = new ObservableDataSource<Point>();
         chartPlotter1.AddLineGraph(source1, Colors.Green, 1, "Устройство 1");
       source2.SetXYMapping(p => p);
        chartPlotter1.AddLineGraph(source2, Colors.Red, 1, "Устройство 2");
      }
    Thread sim_Thread;
    Thread data_receiver;
data_receiver = new Thread(DataReceiverThread);
data_receiver.Priority = ThreadPriority.Highest;
sim_Thread = new Thread((Simulation));
sim_Thread.Priority = ThreadPriority.Highest;
private void DataReceiverThread()//receive data from port
    {
        while (true)
        {
            byte[] data_buf = new byte[480];
            try
            {
                if (serialport.BytesToRead > 480)
                {
                    serialport.Read(data_buf, 0, 480);
                   container.Enqueue(data_buf);
                    data_complete_flag = true;
                    counter++;
                }

            }
            catch (Exception ex)
            { }

        }
    }


private void Simulation()//drawing
    {
        int icount = 0;
        try
        {
            while (true)
            {      
                if (icount < counter)
                    if (data_complete_flag)
                      if ( paket.Parce(container.ElementAt(icount)))
                        { for (int p=0;p<35;p++)
                                    {
                                y = paket.pressure_counter_data1[p];
if (((x = paket.pressure_counter_time1[p]) != 0) && ( y> 0) && (y <111001))
                                        {
                                        Point p1 = new Point(x, y);
                                        source1.AppendAsync(Dispatcher, p1);
                                        }
                                       v = paket.pressure_counter_data2[p];
 if (((z = paket.pressure_counter_time2[p]) != 0) && (v>0) && (v  <111001))
                                        {
                                            Point p2 = new Point(z, v);
                                            source2.AppendAsync(Dispatcher, p2);
                                       }
                                     }
                 icount++;
                       }

            }
        }
        catch (Exception ex)
        { int l = 0; }
    }
how to display the incoming data quickly for a few minutes in real time?