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
Thanks Mike.
I dont know how to insert 15 rows once, is there something like AddRange or are you refering to looping through individual row and adding?
I tried following...
grid.BeginUpdate();
grid.SuspendRowSynchronization();
try{ //Looping through 15 rows and insert } finally{grid.ResumeRowSynchronization(); grid.EndUpdate(); }Also tried commenting out the code for postioning the rows in Grid.No improvement in CPU usage. It looks like there is some problem in DataTable.Rows.InsertAt(row, 0). Thank you,Vinay
try
{
//Looping through 15 rows and insert
}
finally
grid.ResumeRowSynchronization();
grid.EndUpdate();
Also tried commenting out the code for postioning the rows in Grid.No improvement in CPU usage.
It looks like there is some problem in DataTable.Rows.InsertAt(row, 0).
Thank you,
Oh... you should also check out the WinGrid Performance Guide.
There are probably some tips there which you can use to make your grid more efficient and perform better.
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(); }
// insert 15 rows and position them in the grid.