chart stops auto refreshing
Posted: Thu Oct 22, 2009 8:30 am
Hi,
I have a chart with a Points3D series that contains 1000 points. I modify these points in separate thread as fast as possible (performance test application). I tested 2 approaches:
1. Set Chart.AutoRepaint=false and force chart to refresh itself from thread using InvokeRequired/Invoke technique.
2. Set Chart.AutoRepaint=true and do not force chart refresh from the thread.
- Now, disadvantage of first approach is that I can update data only about 10 times per second.
- Second approach let me update data about 90-100 times per second but ocasionally chart stops refreshing. It starts again after moving a window in such a way that forces part of chart to be redrawn (move out of the screen and back). After some time it stops again.
Does anyone can help me either making first approach faster or solving auto refresh problem in second one?!
My code looks like this. To test first approach set autoRepaint=false in Form1 constructor. For second approach set autoRepaint=true:
I have a chart with a Points3D series that contains 1000 points. I modify these points in separate thread as fast as possible (performance test application). I tested 2 approaches:
1. Set Chart.AutoRepaint=false and force chart to refresh itself from thread using InvokeRequired/Invoke technique.
2. Set Chart.AutoRepaint=true and do not force chart refresh from the thread.
- Now, disadvantage of first approach is that I can update data only about 10 times per second.
- Second approach let me update data about 90-100 times per second but ocasionally chart stops refreshing. It starts again after moving a window in such a way that forces part of chart to be redrawn (move out of the screen and back). After some time it stops again.
Does anyone can help me either making first approach faster or solving auto refresh problem in second one?!
My code looks like this. To test first approach set autoRepaint=false in Form1 constructor. For second approach set autoRepaint=true:
Code: Select all
namespace TChart3DAnimation
{
public partial class Form1 : Form
{
private bool autoRepaint;
public Form1()
{
InitializeComponent();
this.autoRepaint = false;
//Here goes data initialisation and thread is started
}
public static void AnimationThreadProc(object data)
{
Form1 _this = data as Form1;
if (_this != null)
{
while (!_this.stopAnimationThread)
{
_this.points3D1.BeginUpdate(); //Steema.TeeChart.Styles.Points3D object created by designer
//here goes data modification
_this.points3D1.EndUpdate();
if (!_this.autoRepaint)
_this.ThreadChartInvoker(_this.tChart1, eTCI.e_TCI_Refresh, null);
System.Threading.Thread.Sleep(5);
}
}
}
private enum eTCI { e_TCI_Refresh };
private delegate void ThreadChartInvokerDelegate(Steema.TeeChart.TChart chart, eTCI method, object[] parameters);
private void ThreadChartInvoker(Steema.TeeChart.TChart chart, eTCI method, object[] parameters)
{
if (InvokeRequired)
{
Invoke(new ThreadChartInvokerDelegate(ThreadChartInvoker), new object[] { chart, method, parameters });
}
else
{
switch (method)
{
case eTCI.e_TCI_Refresh:
//this.points3D1.Repaint();
chart.Invalidate();
//this.points3D1.RefreshSeries();
//chart.Refresh();
break;
}
}
}
}
}