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
144
Excess CPU usage by UltraGrid
posted

I have a UltraGrid to which i continously insert rows at the rate of 15rows/sec,  The grid has 50 rows and 14 columns, there is a datatable which am assigning to the datasource propery of the Grid and every time i create a new datarow and insert it to the datatable and then move it to the required postion in the grid.

Code is as follows

//m_dtMessagesView is my datatable

 

DataRow row = m_dtMessagesView.NewRow();

// here is the code to assign values to each column of new datarow i.e. row

 

m_dtMessagesView.Rows.InsertAt(row, 0);

 

 

 

 

 

int listIndex = m_dtMessagesView.Rows.IndexOf(row);

UltraGridRow ultraRow =

this.Rows.GetRowWithListIndex(listIndex);

 

 

if (this.DisplayLayout.Bands[0].Columns[4].SortIndicator == SortIndicator.Descending)

 

 

this.Rows.Move(ultraRow, 0);

This causes excessive CPU usage of 50% at the rate of insertion mentioned above.

I have also used BeginUpdate and EndUpdate as told Infragistic performance Guide. I tried inserting rows without any values to the column, which also had the same CPU usage.

 Thanks in advance,

Vinay

Parents
  • 469350
    Suggested Answer
    Offline posted

    Hi Vinay,

    Inserting a moving rows like this is going to cause the grid to have to do a lot of processing. BeginUpdate and EndUpdate should make a difference, since that will stop the grid from painting, but that only helps if you can use them around a block that adds more than one row.

    You can also make this more efficient by suspending row synchronization.

    grid.BeginUpdate();

    grid.SuspendRowSynchronization();

    try

    {

         // insert 15 rows and position them in the grid.

    }

    finally

    {

    grid.ResumeRowSynchronization();

    grid.EndUpdate();

    }

     

Reply Children