Hi,
We are using UltraWinGrid to display frequently updated data. The datasource is set to BindingSource which in turn takes a dataset. When there are a lot of updates coming in at the same time, the CPU usage spikes. It appears a GUI painting issue because when we shrink the application window to make updating region invisible, CPU usage comes back to normal. Is there a way to optimize grid painting performance? Would virtual mode help?
Thanks.
Simon
Simon,
What version of the grid are you using? I know that a lot of performance improvements were made in the 7.3 release. From what it sounds like, it definitely seems like a painting issue, since the size of the grid directly affects performance. One thought would be that if you know you're getting a large batch of updates at once, you could try wrapping them in a BeginUpdate/EndUpdate block on the grid so that it only needs to paint once.
-Matt
Hi Matt,
Thanks for your reply. We are still on 7.1. How can we wrap painting in BeginUpdate/EndUpdate block? We are using BindingSource so the grid update itself whenever datasource changes. I suppose you mean there is a way that I can suppress grid from repaint itself, then I can batch the updates. Can you give me more details on that?
I meant that you wrap the updates in a BeginUpdate/EndUpdate, unless you are just getting each update one-at-a-time and you have no way of combining them into batch updates. I can't really say when the best places to do this is since I don't know how you're updating the grid, but it'd be something like:
grid.BeginUpdate();
dataSource.Rows[0].Cells[3].Value = "Some New Value";
dataSource.Rows[1].Cells[2].Value = "Happy Happy, Joy Joy";
grid.EndUpdate();
Thanks for the quick reply. We are listening to a datasource for update. So it's not easy to batch the update unless we add throttling into our datasource. I am just wondering whether there is a way to suppress grid's repaint so we can just make force repaint periodically. I set BindingSource.RaiseListChangedEvents = false but grid is still updating/repainting itself.
I'm not entirely sure what could be causing this then. If the grid is getting repainted without any other sort of trigger (i.e. resized, obscured and then made visible, etc), then it must still be getting some sort of notification. You could always prevent the grid from painting through the methods I suggested previously, but the problem is knowing when to start/stop doing this, which is why I suggested looking where you pull in your data. Whn you say you are "listening to a database", you must still be actively doing something that is pulling the data in from the database somewhere, even on a separate thread, so I would look towards that area. I would also consider looking into using 7.3 or later if you have the subscription since you should definitely notice a decent improvement.