Teechart .NET Styles.Series Index out of Bounds

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Wallenstein
Newbie
Newbie
Posts: 5
Joined: Wed Jan 17, 2018 12:00 am

Teechart .NET Styles.Series Index out of Bounds

Post by Wallenstein » Fri Feb 16, 2018 10:51 am

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.


:idea: Could it be that TeeChart ist not thread safe?

Best regards

Wallenstein
Attachments
TeeChartAbsturz-neueTeeChartVersion.png
Screenshot
TeeChartAbsturz-neueTeeChartVersion.png (497.67 KiB) Viewed 15778 times

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: Teechart .NET Styles.Series Index out of Bounds

Post by Christopher » Mon Feb 19, 2018 8:59 am

Wallenstein wrote: :idea: 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
Screenshot from 2018-02-19 09-55-23.png (24.48 KiB) Viewed 15755 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.'
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

Wallenstein
Newbie
Newbie
Posts: 5
Joined: Wed Jan 17, 2018 12:00 am

Re: Teechart .NET Styles.Series Index out of Bounds

Post by Wallenstein » Mon Feb 19, 2018 3:47 pm

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

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: Teechart .NET Styles.Series Index out of Bounds

Post by Christopher » Wed Feb 21, 2018 3:50 pm

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.
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

Wallenstein
Newbie
Newbie
Posts: 5
Joined: Wed Jan 17, 2018 12:00 am

Re: Teechart .NET Styles.Series Index out of Bounds

Post by Wallenstein » Wed Feb 21, 2018 3:59 pm

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

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: Teechart .NET Styles.Series Index out of Bounds

Post by Christopher » Wed Feb 21, 2018 5:48 pm

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.
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

Wallenstein
Newbie
Newbie
Posts: 5
Joined: Wed Jan 17, 2018 12:00 am

Re: Teechart .NET Styles.Series Index out of Bounds

Post by Wallenstein » Tue Apr 03, 2018 8:34 am

Hello Christopher,

We have done various synchronizations in our applications. However we are still suffering from Index-Out-Of-Bounds problems:
KeopsStackTrace.png
KeopsStackTrace.png (55.19 KiB) Viewed 15604 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

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: Teechart .NET Styles.Series Index out of Bounds

Post by Christopher » Wed Apr 04, 2018 8:02 am

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?
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

Post Reply