Page 1 of 1
Teechart .NET Styles.Series Index out of Bounds
Posted: Fri Feb 16, 2018 10:51 am
by 15682836
Hello,
We get spurious error messages with "Index out of Bounds" Exceptions in Steema.TeeChart.Styles.ValueList
[img]TeeChartAbsturz-neueTeeChartVersion.png[/img]
We have an application that makes heavy use of background initialization and update of TeeChart Series.
Could it be that TeeChart ist not thread safe?
Best regards
Wallenstein
Re: Teechart .NET Styles.Series Index out of Bounds
Posted: Mon Feb 19, 2018 8:59 am
by Christopher
Wallenstein wrote:
Could it be that TeeChart ist not thread safe?
It would be more accurate to say that GDI+ is not thread safe [from
here]:
- Screenshot from 2018-02-19 09-55-23.png (24.48 KiB) Viewed 15761 times
TeeChart has no automatic synchronization mechanism because GDI+ has no automatic synchronization mechanism, which means that if you are using a TeeChart object which refers to a GDI+ object in a multithreaded application you will have to 'place the call inside a critical section, or use some other standard synchronization technique.'
Re: Teechart .NET Styles.Series Index out of Bounds
Posted: Mon Feb 19, 2018 3:47 pm
by 15682836
Hello Christopher,
Ah OK. Thank you for your prompt reply.
Unfortunatelly the OnPaint-call is not initiated by us, but by Windows.Forms. So what would be your recommendation for thread based implementations?
How can we ensure that TeeChart is not painting during an series update?
Best regards
Michael
Re: Teechart .NET Styles.Series Index out of Bounds
Posted: Wed Feb 21, 2018 3:50 pm
by Christopher
Wallenstein wrote:
How can we ensure that TeeChart is not painting during an series update?
If the TChart object is running on the same thread as the Series object there is no problem. The problems occur when they are run on different threads. If this is the case, then updates to the Series object should be placed inside a
critical section.
Re: Teechart .NET Styles.Series Index out of Bounds
Posted: Wed Feb 21, 2018 3:59 pm
by 15682836
Hello Christopher,
If the TChart object is running on the same thread as the Series object there is no problem. The problems occur when they are run on different threads. If this is the case, then updates to the Series object should be placed inside a critical section.
Yes that is clear, however your example of an critical section requires a lock:
Code: Select all
lock (thisLock) {
... do something critical
}
What is the
thisLock-Object that is also used by teechart to synchronize the paint-Method?
Michael
Re: Teechart .NET Styles.Series Index out of Bounds
Posted: Wed Feb 21, 2018 5:48 pm
by Christopher
Hello,
Wallenstein wrote:
What is the thisLock-Object that is also used by teechart to synchronize the paint-Method?
To quote from the link in my last message:
Best practice is to define a private object to lock on, or a private static object variable to protect data common to all instances.
as it's a private object then it is not used outside the thread in which it is defined.
Re: Teechart .NET Styles.Series Index out of Bounds
Posted: Tue Apr 03, 2018 8:34 am
by 15682836
Hello Christopher,
We have done various synchronizations in our applications. However we are still suffering from Index-Out-Of-Bounds problems:
- KeopsStackTrace.png (55.19 KiB) Viewed 15610 times
As you see from this stacktrace, the FastLine Draw-Method is Inserting Values into the ValueList.
Why is it doing this? What points are here inserted? The FastLine was already be filled with all necessary points.
Best regards
Michael
Re: Teechart .NET Styles.Series Index out of Bounds
Posted: Wed Apr 04, 2018 8:02 am
by Christopher
Hello Michael,
Wallenstein wrote:
Why is it doing this? What points are here inserted? The FastLine was already be filled with all necessary points.
the FastLine series fills an internal valuelist with values when its Clicked() method is called as a speed optimization, and this Clicked() method is called by the MarksTip tool. Just by looking at the code I can't imagine why it should fail, and certainly all the tests I've run on the code haven't caused it to fail in this way, e.g.
Code: Select all
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
FastLine series1 = new FastLine(tChart1.Chart);
series1.FillSampleValues(10000);
series1.DrawAllPoints = false;
MarksTip tool1 = new MarksTip(tChart1.Chart);
tool1.Series = series1;
}
In order to resolve this issue I will need some code with which I can reproduce it here - could you please provide me with some?