Page 1 of 1

Chart multiple threads access

Posted: Wed Jun 16, 2010 3:07 pm
by 10055200
Hi,

I have a question regarding usage of teechart within multiple threads. I have two chart which are very similar one to each other. Actually one is descendant of other. The descendant chart has logarithmic bottom scale. I have vertical cursors on both. If I move cursor on ascendant chart everything works ok regardless if i move cursor on descendant chart i get teechart access violation which happens somewhere in teechart. It is also very hard to catchbug while it is not always possible to repeat it. Sometimes works and sometimes it crashes. I isolated almost everything and now I am suspecting that there must be somehow multi thread access problem. I have one thread which is populating graphs with some data and other thread does the rest job (mouse events etc...) Is it possible to lock chart that only one thread would have access at same time? Something similar like with critical section.

Re: Chart multiple threads access

Posted: Thu Jun 17, 2010 2:59 pm
by yeray
Hi PoLabs,
PoLabs wrote:I have one thread which is populating graphs with some data and other thread does the rest job (mouse events etc...) Is it possible to lock chart that only one thread would have access at same time? Something similar like with critical section.
I'm afraid that TeeChart isn't thread safe. This means that you should ensure that the repainting of the chart isn't interfered with an addition of a point. To do this, you should set autorepaint property to false and pause the "acquiring data thread" before repainting the chart (Chart1.Repaint) and let it continue when the repaint has finished, for example using semaphores.

Re: Chart multiple threads access

Posted: Fri Jun 18, 2010 7:12 am
by 10055200
I will pay attention to that. I also soved my problem and it was not related to threads. Thanks for reply and suggestion.

Re: Chart multiple threads access

Posted: Fri Jun 18, 2010 11:10 am
by yeray
Hi PoLabs,

You're welcome! I'm pleased to hear that you've solved it.