Hi
I implemented IChartSeriesModel in a candlestick chart.
My data source in my model is List
I subscribe to the IChartSeriesModel.Changed event from the calling class. Then handler is an empty function, because I just want the chart to update.
When I update my model and fire off Changed, the chart updates accordingly, However, the chart updates very slowly.
My app is trying to update the chart with each tick about 500 times per second.
But when I run diagnostics on Change.Invoke, it takes about 100 ms each time. I ran diagnostics on the code leading up to this line and everything else was fast except this.
What can I look at to make it fire and update faster?
Please let me know if you need other info.
Hi Gayathri,
I experimented with the sample and found some hints.
I tried to zip the entire solution but it was too big (maybe because vs 2022 forced me to upgrade the solution to .net framwork 4.8), so I just uploaded a zip with the Form1.Designer.cs file.
I made some significant changes including adding an async call to update hourly bars with 'ticks' and then add a new bar after each hour is complete.
But the behavior really starts to show itself when:
1) I set Indexed to true. (I still need this behavior because I cannot have weekend gaps).
2) I add 3000-4000 starting bars to the chart (experiment with the startingBars variable on line 73, see how fast it updates when you set it to 40 vs 4000 or more)
I know that setting Indexed = false will improve performance, but 1 - I can't have weekend gaps, 2) you will see that if you set Indexed = false and run it, the behavior will be really weird where the active bar kind of 'walks from left to right'.
I feel like a few thousand bars is a really small number to be diminishing the performance of the chart. Shouldn't the chart be able to handle much more than that?
Thanks All,
I did some deeper research, and the true solution is that winforms is the wrong approach when one wants very fast constant updates to controls, because it runs on the Windows message loop, which will always run into issues for fast updates. The better solution is WPF because it uses DirectX.
I got the hint from this
Thanks again everyone.