Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
750
ultragrid perf issue adding and removing columns
posted

Hi,

 

I've searched a little bit in this form and can't find a clear match.

I'm dynamically adding and removing columns from the datasource backing a grid.  I am experiencing huge delays. I've tried using SuspendRowSync, SuspendLayout and SuspendCalc properly contained within a BeginUpdate and try finally block with an EndUpdate (I didn't forget the appropriate Resume call).  However none of these alleviate the performance problem.

I looked at the Grid Performance Guide and nothing jumped out at me.

I've used the Red Gate performance profiler to track down the performance issue. See attached compressed  file that contains the call graph locked at the function occupies 89% of the time. In that function, it spends a majority of the time in Add/Remove columns on the UltraDataSource. Also it's clear that it's triggered a recalc and the recursive descent parser is parsing the calc code for the grid.

How can I improve the performance here? Perhaps I misapplied SuspendCalc? Can I force the CalcManager to fire once and statically create the code for the computations  and not recompute them again?

 

Any suggestions are appreciated.

 

Craig

 

add-remove-columns-perf.zip
Parents
No Data
Reply
  • 469350
    Offline posted

    Hi Craig,

    A screen shot of the profiler results isn't much help. But from what little I can see here, it looks like SuspendCalc would help.

    It could be that the SuspendCalc is not helping because the grid is responding to the changes in the column structure asynchronously. So your ResumeCalc may have already been called before any of the processing by the grid begins. The same might be true of the calculations. Since the calculations are performed Asynchonrously, they might not be happening until after you call ResumeCalc.

    It's very hard to guess without seeing the problem first-hand. Can you post a small sample project demonstrating the issue?

    If not, then my suggestion would be to try setting the CalcFrequency on the CalcManager to Manual. That should prevent all calculations from occurring.

    You should still use BeginUpdate and EndUpdate around the code that adds/removes the columns. And don't reset the CalcFrequency back to normal until after the EndUpdate.

    I don't think SuspendRowSynrchonization will help, but I could be wrong, and it can't hurt. But SuspendLayout will not do anything, so you don't need that.

    Also, it might be a good idea to use AddRange to add all of the columns at once instead of one at a time, if you can.

     

     

     

Children