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
1330
Intolerable lag with UltraComboEditor
posted

Hello I have come across some strange symptoms associated with retrieving data for a bound UltraComboEditor control.  I have provided code to reproduce this problem I'm having.  The problem is:

When you run the example the comboBoxes on the left are not bound until you click the button to the left.  When this button is clicked the UltraComboBoces are bound each to an unique table in the typed DataSet.  Immediately after PopulateTables is called to put 1000 rows of data into each table.  (populate tables is meant to mimic a call to a back end for data).  This process takes ~20ms.

The second set of comboBoxes (on the right) were previously bound in the designer (thus their bindings are assigned in InitializeComponent.  When you click the button beside these we call PopulateTables.  This takes ~ 13000ms or ~13 seconds to fill the comboBoxes.

My question is, why does this happen?  The 13 seconds of lag is intolerable.  This makes absolutely no sense to me why filling on one set takes ~22ms and the other set takes ~13000ms.

To get the code to work.  Open a new WindowsApplication Project in VS and just replace the program.cs text with the following code.

static class Program1

    {

        /// <summary>

        /// The main entry point for the application.

        /// </summary>

        [STAThread]

        static void Main()

        {

            Application.EnableVisualStyles();

            Application.SetCompatibleTextRenderingDefault(false);

            Application.Run(new Form5());

        }

    }

 

    class TypedDataSet : DataSet

    {

        public TypedDataSet()

        {

            DataTable t1 = new DataTable();

            t1.Columns.Add("one", typeof(string));

            t1.Columns.Add("two", typeof(string));

            t1.TableName = "TableOne";

            this.Tables.Add(t1);

 

            DataTable t2 = new DataTable();

            t2.Columns.Add("one", typeof(string));

            t2.Columns.Add("two", typeof(string));

            t2.TableName = "TableTwo";

            this.Tables.Add(t2);

 

            DataTable t3 = new DataTable();

            t3.Columns.Add("one", typeof(string));

            t3.Columns.Add("two", typeof(string));

            t3.TableName = "TableThree";

            this.Tables.Add(t3);

 

            DataTable t4 = new DataTable();

            t4.Columns.Add("one", typeof(string));

            t4.Columns.Add("two", typeof(string));

            t4.TableName = "TableFour";

            this.Tables.Add(t4);

 

        }

    }

 

    public partial class Form5 : Form

    {

        Random rnd = new Random();

        public static Stopwatch stopwatch1 = new Stopwatch();

 

        public Form5()

        {

            InitializeComponent();

        }

 

        private void button1_Click(object sender, EventArgs e)

        {

            List<UltraComboEditor> uceList = new List<UltraComboEditor>();

            uceList.Add(ultraComboEditor1);

            uceList.Add(ultraComboEditor2);

            uceList.Add(ultraComboEditor3);

            uceList.Add(ultraComboEditor4);

            TypedDataSet tds = new TypedDataSet();

            for (int i = 0; i < tds.Tables.Count; i++)

            {

                UltraComboEditor uce = uceList[i];

                uce.DataSource = tds;

                uce.DataMember = tds.Tables[i].TableName;

                uce.DisplayMember = tds.Tables[i].TableName + ".one";

            }

 

            stopwatch1.Reset();

            stopwatch1.Start();

            PupulateTables(tds);

            stopwatch1.Stop();

            MessageBox.Show("Time taken: " + stopwatch1.ElapsedMilliseconds + "ms");

        }

 

        private void button3_Click(object sender, EventArgs e)

        {

            stopwatch1.Reset();

            stopwatch1.Start();

            PupulateTables(typedDataSet1);

            stopwatch1.Stop();

            MessageBox.Show("Time taken: " + stopwatch1.ElapsedMilliseconds + "ms");

        }

 

        private void PupulateTables(DataSet dataSet1)

        {

            foreach (DataTable dt in dataSet1.Tables)

            {

                PopulateTable(dt, 1000);

            }

        }

 

        /// <summary>

        /// Populates a table with a specified number of rows.

        /// </summary>

        /// <param name="t">The table.</param>

        /// <param name="rows">The rows.</param>

        public void PopulateTable(DataTable t, int rows)

        {

            for (int i = 0; i < rows; i++)

            {

                DataRow dtrRow = t.NewRow();

                for (int co = 0; co < dtrRow.ItemArray.Length; co++)

                {

                    dtrRow[co] = GetRandomString(4);

                }

                t.Rows.Add(dtrRow);

            }

        }

 

        /// <summary>

        /// Gets the random string.

        /// </summary>

        /// <param name="length">The length.</param>

        /// <returns></returns>

        public string GetRandomString(int length)

        {

            string charPool

            = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvw xyz1234567890";

            StringBuilder rs = new StringBuilder();

            int counter = 0;

            while (counter != length)

            {

                rs.Append(charPool[rnd.Next(0, charPool.Length)]);

                counter++;

            }

            return rs.ToString();

        }

        #region Windows Form Designer generated code

 

        /// <summary>

        /// Required method for Designer support - do not modify

        /// the contents of this method with the code editor.

        /// </summary>

        private void InitializeComponent()

        {

            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form4));

            this.ultraComboEditor1 = new Infragistics.Win.UltraWinEditors.UltraComboEditor();

            this.ultraComboEditor2 = new Infragistics.Win.UltraWinEditors.UltraComboEditor();

            this.ultraComboEditor3 = new Infragistics.Win.UltraWinEditors.UltraComboEditor();

            this.ultraComboEditor4 = new Infragistics.Win.UltraWinEditors.UltraComboEditor();

            this.button1 = new System.Windows.Forms.Button();

 

            this.button3 = new System.Windows.Forms.Button();

            this.ultraComboEditor8 = new Infragistics.Win.UltraWinEditors.UltraComboEditor();

            this.typedDataSet1 = new DataBindingLagProblem.TypedDataSet();

            this.ultraComboEditor5 = new Infragistics.Win.UltraWinEditors.UltraComboEditor();

            this.ultraComboEditor6 = new Infragistics.Win.UltraWinEditors.UltraComboEditor();

            this.ultraComboEditor7 = new Infragistics.Win.UltraWinEditors.UltraComboEditor();

            ((System.ComponentModel.ISupportInitialize)(this.ultraComboEditor1)).BeginInit();

            ((System.ComponentModel.ISupportInitialize)(this.ultraComboEditor2)).BeginInit();

            ((System.ComponentModel.ISupportInitialize)(this.ultraComboEditor3)).BeginInit();

            ((System.ComponentModel.ISupportInitialize)(this.ultraComboEditor4)).BeginInit();

            ((System.ComponentModel.ISupportInitialize)(this.ultraComboEditor8)).BeginInit();

            ((System.ComponentModel.ISupportInitialize)(this.typedDataSet1)).BeginInit();

            ((System.ComponentModel.ISupportInitialize)(this.ultraComboEditor5)).BeginInit();

            ((System.ComponentModel.ISupportInitialize)(this.ultraComboEditor6)).BeginInit();

            ((System.ComponentModel.ISupportInitialize)(this.ultraComboEditor7)).BeginInit();

            this.SuspendLayout();

            // 

            // ultraComboEditor1

            // 

            this.ultraComboEditor1.Location = new System.Drawing.Point(105, 12);

            this.ultraComboEditor1.Name = "ultraComboEditor1";

            this.ultraComboEditor1.Size = new System.Drawing.Size(144, 21);

            this.ultraComboEditor1.TabIndex = 0;

            this.ultraComboEditor1.Text = "ultraComboEditor1";

            // 

            // ultraComboEditor2

            // 

            this.ultraComboEditor2.Location = new System.Drawing.Point(105, 39);

            this.ultraComboEditor2.Name = "ultraComboEditor2";

            this.ultraComboEditor2.Size = new System.Drawing.Size(144, 21);

            this.ultraComboEditor2.TabIndex = 1;

            this.ultraComboEditor2.Text = "ultraComboEditor2";

            // 

            // ultraComboEditor3

            // 

            this.ultraComboEditor3.Location = new System.Drawing.Point(105, 66);

            this.ultraComboEditor3.Name = "ultraComboEditor3";

            this.ultraComboEditor3.Size = new System.Drawing.Size(144, 21);

            this.ultraComboEditor3.TabIndex = 2;

            this.ultraComboEditor3.Text = "ultraComboEditor3";

            // 

            // ultraComboEditor4

            // 

            this.ultraComboEditor4.Location = new System.Drawing.Point(105, 93);

            this.ultraComboEditor4.Name = "ultraComboEditor4";

            this.ultraComboEditor4.Size = new System.Drawing.Size(144, 21);

            this.ultraComboEditor4.TabIndex = 3;

            this.ultraComboEditor4.Text = "ultraComboEditor4";

            // 

            // button1

            // 

            this.button1.Location = new System.Drawing.Point(12, 5);

            this.button1.Name = "button1";

            this.button1.Size = new System.Drawing.Size(87, 23);

            this.button1.TabIndex = 4;

            this.button1.Text = "Bind";

            this.button1.UseVisualStyleBackColor = true;

            this.button1.Click += new System.EventHandler(this.button1_Click);

 

 

            // 

            // button3

            // 

            this.button3.Location = new System.Drawing.Point(288, 5);

            this.button3.Name = "button3";

            this.button3.Size = new System.Drawing.Size(87, 23);

            this.button3.TabIndex = 10;

            this.button3.Text = "Bind";

            this.button3.UseVisualStyleBackColor = true;

            this.button3.Click += new System.EventHandler(this.button3_Click);

            // 

            // ultraComboEditor8

            // 

            this.ultraComboEditor8.DataMember = "TableFour";

            this.ultraComboEditor8.DataSource = this.typedDataSet1;

            this.ultraComboEditor8.DisplayMember = "one";

            this.ultraComboEditor8.Location = new System.Drawing.Point(381, 93);

            this.ultraComboEditor8.Name = "ultraComboEditor8";

            this.ultraComboEditor8.Size = new System.Drawing.Size(144, 21);

            this.ultraComboEditor8.TabIndex = 6;

            this.ultraComboEditor8.Text = "ultraComboEditor8";

            // 

            // typedDataSet1

            // 

            this.typedDataSet1.DataSetName = "NewDataSet";

            // 

            // ultraComboEditor5

            // 

            this.ultraComboEditor5.DataMember = "TableOne";

            this.ultraComboEditor5.DataSource = this.typedDataSet1;

            this.ultraComboEditor5.DisplayMember = "one";

            this.ultraComboEditor5.Location = new System.Drawing.Point(381, 12);

            this.ultraComboEditor5.Name = "ultraComboEditor5";

            this.ultraComboEditor5.Size = new System.Drawing.Size(144, 21);

            this.ultraComboEditor5.TabIndex = 11;

            this.ultraComboEditor5.Text = "ultraComboEditor5";

            // 

            // ultraComboEditor6

            // 

            this.ultraComboEditor6.DataMember = "TableTwo";

            this.ultraComboEditor6.DataSource = this.typedDataSet1;

            this.ultraComboEditor6.DisplayMember = "one";

            this.ultraComboEditor6.Location = new System.Drawing.Point(381, 39);

            this.ultraComboEditor6.Name = "ultraComboEditor6";

            this.ultraComboEditor6.Size = new System.Drawing.Size(144, 21);

            this.ultraComboEditor6.TabIndex = 12;

            this.ultraComboEditor6.Text = "ultraComboEditor6";

            // 

            // ultraComboEditor7

            // 

            this.ultraComboEditor7.DataMember = "TableThree";

            this.ultraComboEditor7.DataSource = this.typedDataSet1;

            this.ultraComboEditor7.DisplayMember = "one";

            this.ultraComboEditor7.Location = new System.Drawing.Point(381, 66);

            this.ultraComboEditor7.Name = "ultraComboEditor7";

            this.ultraComboEditor7.Size = new System.Drawing.Size(144, 21);

            this.ultraComboEditor7.TabIndex = 13;

            this.ultraComboEditor7.Text = "ultraComboEditor7";

            // 

            // Form4

            // 

            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);

            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;

            this.ClientSize = new System.Drawing.Size(636, 206);

            this.Controls.Add(this.ultraComboEditor7);

            this.Controls.Add(this.ultraComboEditor6);

            this.Controls.Add(this.ultraComboEditor5);

            this.Controls.Add(this.button3);

            this.Controls.Add(this.ultraComboEditor8);

            this.Controls.Add(this.button1);

            this.Controls.Add(this.ultraComboEditor4);

            this.Controls.Add(this.ultraComboEditor3);

            this.Controls.Add(this.ultraComboEditor2);

            this.Controls.Add(this.ultraComboEditor1);

            this.Name = "Form4";

            this.Text = "Form4";

            ((System.ComponentModel.ISupportInitialize)(this.ultraComboEditor1)).EndInit();

            ((System.ComponentModel.ISupportInitialize)(this.ultraComboEditor2)).EndInit();

            ((System.ComponentModel.ISupportInitialize)(this.ultraComboEditor3)).EndInit();

            ((System.ComponentModel.ISupportInitialize)(this.ultraComboEditor4)).EndInit();

            ((System.ComponentModel.ISupportInitialize)(this.ultraComboEditor8)).EndInit();

            ((System.ComponentModel.ISupportInitialize)(this.typedDataSet1)).EndInit();

            ((System.ComponentModel.ISupportInitialize)(this.ultraComboEditor5)).EndInit();

            ((System.ComponentModel.ISupportInitialize)(this.ultraComboEditor6)).EndInit();

            ((System.ComponentModel.ISupportInitialize)(this.ultraComboEditor7)).EndInit();

            this.ResumeLayout(false);

            this.PerformLayout();

        }

 

        #endregion

 

        private Infragistics.Win.UltraWinEditors.UltraComboEditor ultraComboEditor1;

        private Infragistics.Win.UltraWinEditors.UltraComboEditor ultraComboEditor2;

        private Infragistics.Win.UltraWinEditors.UltraComboEditor ultraComboEditor3;

        private Infragistics.Win.UltraWinEditors.UltraComboEditor ultraComboEditor4;

        private System.Windows.Forms.Button button1;

        private Infragistics.Win.UltraWinEditors.UltraComboEditor ultraComboEditor8;

        private System.Windows.Forms.Button button3;

        private TypedDataSet typedDataSet1;

        private Infragistics.Win.UltraWinEditors.UltraComboEditor ultraComboEditor5;

        private Infragistics.Win.UltraWinEditors.UltraComboEditor ultraComboEditor6;

        private Infragistics.Win.UltraWinEditors.UltraComboEditor ultraComboEditor7;

    }

 

 

 

 

 

Parents
No Data
Reply
  • 469350
    Offline posted

    I tried putting your sample code into a new project, but it's extremely difficult to do, since this doesn't include references, the form code is missing, and there are no includes.

    Could you post a small sample project that I can run to see the problem occur?

Children