Code execution very slow with C#, expecially the InitializeComponent()

  • Thread starter Thread starter Gianco
  • Start date Start date
G

Gianco

Hello

I'm developing an application on a PC with an ARMV4I processor (400
MHZ) with C# .NET compact framework and everything seems slow, slow,
slow...

Probably I'm unable to write optimized code, but now I have some
suspects about the quality of the finally generated code

I would know your opinion about this: Is it normal for you that, the
following InitializeComponent procedure takes 2.7 seconds to be
executed???

This time was measured running the application from the C# IDE,
"Release Mode", after dropped all the previously used bitmaps to have
more memory, the exe size is 520 KB. There aren't threads defined by
me. In this routine I use a custom control but nothing happens if I
remove the custom control. If this "super optimized automatically
generated code" is so slow, imagine the rest of the program...

private void InitializeComponent()
{
this.pctTitolo = new System.Windows.Forms.PictureBox();
this.lblID_CAT_UM = new System.Windows.Forms.Label();
this.cmbID_CAT_UM = new System.Windows.Forms.ComboBox();
this.txtDescrizione = new System.Windows.Forms.TextBox();
this.lblDescrizione = new System.Windows.Forms.Label();
this.btnSalva = new System.Windows.Forms.Button();
this.btnAnnulla = new System.Windows.Forms.Button();
this.lblID_UM_RIFER = new System.Windows.Forms.Label();
this.cmbID_UM_RIFER = new System.Windows.Forms.ComboBox();
this.lblCOEFF_UM_RIFER = new System.Windows.Forms.Label();
this.numtxtCOEFF_UM_RIFER = new BLM.NumTextBox();
this.chkFlagUmRifer = new System.Windows.Forms.CheckBox();
//
// pctTitolo
//
this.pctTitolo.Location = new System.Drawing.Point(14, 5);
this.pctTitolo.Size = new System.Drawing.Size(772, 30);
//
// lblID_CAT_UM
//
this.lblID_CAT_UM.Font = new
System.Drawing.Font("Microsoft Sans Serif", 8.25F,
System.Drawing.FontStyle.Regular);
this.lblID_CAT_UM.Location = new System.Drawing.Point(24,
56);
this.lblID_CAT_UM.Size = new System.Drawing.Size(216, 20);
this.lblID_CAT_UM.Text = "Categoria U.M.";
//
// cmbID_CAT_UM
//
this.cmbID_CAT_UM.Location = new System.Drawing.Point(24,
88);
this.cmbID_CAT_UM.Size = new System.Drawing.Size(216, 21);
//
// txtDescrizione
//
this.txtDescrizione.Location = new
System.Drawing.Point(344, 88);
this.txtDescrizione.Size = new System.Drawing.Size(344,
20);
this.txtDescrizione.Text = "";
this.txtDescrizione.LostFocus += new
System.EventHandler(this.txtDescrizione_LostFocus);
//
// lblDescrizione
//
this.lblDescrizione.Font = new
System.Drawing.Font("Microsoft Sans Serif", 8.25F,
System.Drawing.FontStyle.Regular);
this.lblDescrizione.Location = new
System.Drawing.Point(344, 56);
this.lblDescrizione.Size = new System.Drawing.Size(344,
20);
this.lblDescrizione.Text = "Descrizione U.M.";
//
// btnSalva
//
this.btnSalva.Font = new System.Drawing.Font("Tahoma",
14.25F, System.Drawing.FontStyle.Regular);
this.btnSalva.Location = new System.Drawing.Point(240,
272);
this.btnSalva.Size = new System.Drawing.Size(144, 56);
this.btnSalva.Text = "Salva";
this.btnSalva.Click += new
System.EventHandler(this.btnSalva_Click);
//
// btnAnnulla
//
this.btnAnnulla.Font = new System.Drawing.Font("Tahoma",
14.25F, System.Drawing.FontStyle.Regular);
this.btnAnnulla.Location = new System.Drawing.Point(416,
272);
this.btnAnnulla.Size = new System.Drawing.Size(144, 56);
this.btnAnnulla.Text = "Annulla";
this.btnAnnulla.Click += new
System.EventHandler(this.btnAnnulla_Click);
//
// lblID_UM_RIFER
//
this.lblID_UM_RIFER.Font = new
System.Drawing.Font("Microsoft Sans Serif", 8.25F,
System.Drawing.FontStyle.Regular);
this.lblID_UM_RIFER.Location = new
System.Drawing.Point(24, 184);
this.lblID_UM_RIFER.Size = new System.Drawing.Size(216,
20);
this.lblID_UM_RIFER.Text = "U.M. di Riferimento";
//
// cmbID_UM_RIFER
//
this.cmbID_UM_RIFER.Location = new
System.Drawing.Point(24, 216);
this.cmbID_UM_RIFER.Size = new System.Drawing.Size(216,
21);
//
// lblCOEFF_UM_RIFER
//
this.lblCOEFF_UM_RIFER.Font = new
System.Drawing.Font("Microsoft Sans Serif", 8.25F,
System.Drawing.FontStyle.Regular);
this.lblCOEFF_UM_RIFER.Location = new
System.Drawing.Point(344, 184);
this.lblCOEFF_UM_RIFER.Size = new System.Drawing.Size(344,
20);
this.lblCOEFF_UM_RIFER.Text = "Fattore di Conversione";
//
// numtxtCOEFF_UM_RIFER
//
this.numtxtCOEFF_UM_RIFER.AllowAllInput = false;
this.numtxtCOEFF_UM_RIFER.AllowNegative = true;
this.numtxtCOEFF_UM_RIFER.BeepOnError = false;
this.numtxtCOEFF_UM_RIFER.Location = new
System.Drawing.Point(344, 216);
this.numtxtCOEFF_UM_RIFER.MaxValue = 99999.9999999;
this.numtxtCOEFF_UM_RIFER.MinValue = 0;
this.numtxtCOEFF_UM_RIFER.NumDecimalDigits = 7;
this.numtxtCOEFF_UM_RIFER.NumIntegerDigits = 5;
this.numtxtCOEFF_UM_RIFER.RoundIntValue = true;
this.numtxtCOEFF_UM_RIFER.Size = new
System.Drawing.Size(96, 20);
this.numtxtCOEFF_UM_RIFER.Text = "0";
this.numtxtCOEFF_UM_RIFER.ValidateTextOnLostFocus = true;
this.numtxtCOEFF_UM_RIFER.Value = 0;
this.numtxtCOEFF_UM_RIFER.WordWrap = false;
//
// chkFlagUmRifer
//
this.chkFlagUmRifer.Location = new
System.Drawing.Point(24, 136);
this.chkFlagUmRifer.Size = new System.Drawing.Size(296,
24);
this.chkFlagUmRifer.Text = "Esiste una U.M. di
Riferimento";
this.chkFlagUmRifer.CheckStateChanged += new
System.EventHandler(this.chkFlagUmRifer_CheckStateChanged);
this.FormBorderStyle =
System.Windows.Forms.FormBorderStyle.None;
//
// frmEditUM
//
this.ClientSize = new System.Drawing.Size(794, 575);
this.ControlBox = false;
this.Controls.Add(this.pctTitolo);
this.Controls.Add(this.lblID_CAT_UM);
this.Controls.Add(this.cmbID_CAT_UM);
this.Controls.Add(this.txtDescrizione);
this.Controls.Add(this.lblDescrizione);
this.Controls.Add(this.chkFlagUmRifer);
this.Controls.Add(this.lblID_UM_RIFER);
this.Controls.Add(this.cmbID_UM_RIFER);
this.Controls.Add(this.lblCOEFF_UM_RIFER);
this.Controls.Add(this.numtxtCOEFF_UM_RIFER);
this.Controls.Add(this.btnSalva);
this.Controls.Add(this.btnAnnulla);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Closed += new
System.EventHandler(this.frmEditUM_Closed);
}

The InitializeComponent() is slow not only for this form but always

Can anyone save me so I haven't to rewrite all my program with Visual
C++ ???

Thanks in advance
Gianco
 
There is a third party VS add-in which will perform the optimisations for
you....

http://www.mrgsoft.com

It costs around $25 for a single licence, it works great.

Also, if you are running PPC2002 or PPC2000, then I have found that
upgrading to PPC2003 makes a BIG difference.

Chris
 
Back
Top