Использую NET CF 2.0, C#, Visual Studio 2005, Windows Mobile 5.0(или 6.1) . При запуске программы на КПК инициализирую формы (компоненты на форме), чтобы в дальнейшем они быстро открывались. На КПК — достаточно свободной памяти для выполнения этой операции Примерно в 10%-20% случаев первоначальной инициализации этих форм при запуске программы — программа зависает, то есть перестают обрабатываться (показываться окна) в главной форме, откуда я инициализирую другие формы. Помогите разобраться. Проблема явно не в какой-то конкретной форме. Если ее забираю из инициализации, то виснет на какой-то другой и как я уже писал — не всегда. Фрагменты кодаMainForm.cs| Код | void InitializeAsync()//главная процедура инициализации { //...тут также инициализируется несколько форм Classes.Loader.Instance.SetSubCaption("Форма 'Настройки 1'...");//данное сообщение показывается всегда this.InitializeSyncForm(Forms.Forms.MessageBoxEx); Classes.Loader.Instance.SetSubCaption("Форма 'Настройки 2'...");//данное сообщение в 10-20% случаев инициализации не показывается this.InitializeSyncForm(Forms.Forms.MessageBoxEx2); //...тут также инициализируется несколько форм } Form CreateFormByType(Forms.Forms form)//вызов инициализации формы { switch (form) { case Forms.Forms.MessageBoxEx: return MessageBoxEx.Instance; case Forms.Forms.MessageBoxEx2: return MessageBoxEx2.Instance; } return null; } void InitializeSyncForm(Forms.Forms value) { if (this.InvokeRequired) { this.Invoke ( new MethodDelegate<Forms.Forms>(InitializeSyncForm), new object[] { value } ); return; } if (_forms == null) _forms = new Dictionary<Forms.Forms, Form>(); this._forms.Add(value, CreateFormByType(value)); }
|
MessageBoxEx.cs| Код | private MessageBoxEx() { InitializeComponent(); } public static MessageBoxEx Instance { get { if (_instance == null) _instance = new MessageBoxEx(); return _instance; } }
|
MessageBoxEx.Designer.cs| Код | private void InitializeComponent() { this.mainMenu1 = new System.Windows.Forms.MainMenu(); this.panel1 = new System.Windows.Forms.Panel(); this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.button1 = new System.Windows.Forms.Button(); this.button2 = new System.Windows.Forms.Button(); this.button3 = new System.Windows.Forms.Button(); this.button4 = new System.Windows.Forms.Button(); this.button5 = new System.Windows.Forms.Button(); this.panel1.SuspendLayout(); this.SuspendLayout(); // // panel1 // this.panel1.BackColor = System.Drawing.SystemColors.ActiveCaption; this.panel1.Controls.Add(this.label1); this.panel1.Dock = System.Windows.Forms.DockStyle.Top; this.panel1.Location = new System.Drawing.Point(0, 0); this.panel1.Name = "panel1"; this.panel1.Size = new System.Drawing.Size(236, 21); // // label1 // this.label1.BackColor = System.Drawing.SystemColors.ActiveCaption; this.label1.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Bold); this.label1.ForeColor = System.Drawing.SystemColors.ActiveCaptionText; this.label1.Location = new System.Drawing.Point(2, 3); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(100, 20); this.label1.Text = "Обновление"; // // label2 // this.label2.ForeColor = System.Drawing.SystemColors.WindowText; this.label2.Location = new System.Drawing.Point(14, 24); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(208, 52); this.label2.Text = "Обновление"; // // button1 // this.button1.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Bold); this.button1.Location = new System.Drawing.Point(3, 79); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(72, 20); this.button1.TabIndex = 2; this.button1.Text = "Да"; this.button1.Click += new System.EventHandler(this.button1_Click); // // button2 // this.button2.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Bold); this.button2.Location = new System.Drawing.Point(24, 105); this.button2.Name = "button2"; this.button2.Size = new System.Drawing.Size(87, 20); this.button2.TabIndex = 2; this.button2.Text = "Да для всех"; this.button2.Click += new System.EventHandler(this.button2_Click); // // button3 // this.button3.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Bold); this.button3.Location = new System.Drawing.Point(81, 79); this.button3.Name = "button3"; this.button3.Size = new System.Drawing.Size(72, 20); this.button3.TabIndex = 2; this.button3.Text = "Нет"; this.button3.Click += new System.EventHandler(this.button3_Click); // // button4 // this.button4.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Bold); this.button4.Location = new System.Drawing.Point(159, 79); this.button4.Name = "button4"; this.button4.Size = new System.Drawing.Size(72, 20); this.button4.TabIndex = 2; this.button4.Text = "Отмена"; this.button4.Click += new System.EventHandler(this.button4_Click); // // button5 // this.button5.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Bold); this.button5.Location = new System.Drawing.Point(117, 105); this.button5.Name = "button5"; this.button5.Size = new System.Drawing.Size(87, 20); this.button5.TabIndex = 2; this.button5.Text = "Нет для всех"; this.button5.Click += new System.EventHandler(this.button5_Click); // // MessageBoxEx // this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; this.AutoScroll = true; this.ClientSize = new System.Drawing.Size(236, 134); this.ControlBox = false; this.Controls.Add(this.button5); this.Controls.Add(this.button2); this.Controls.Add(this.button4); this.Controls.Add(this.button3); this.Controls.Add(this.button1); this.Controls.Add(this.label2); this.Controls.Add(this.panel1); this.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; this.Menu = this.mainMenu1; this.Name = "MessageBoxEx"; this.TopMost = true; this.panel1.ResumeLayout(false); this.ResumeLayout(false);
}
|
|