2013-09-02 2 views
0

나는 즉시 프로젝트를 시작으로 또 다른 형태의로드 내 주요 형태로 일부 코드가 표시되지 않습니다양식이 제대로

private void Form1_Load(object sender, EventArgs e) 
    { 
     Updating upd = new Updating(); 
     upd.Show(); 
    } 

이 새로운 형태의 (현재) 바로이 코드가 포함

private void Updating_Load(object sender, EventArgs e) 
    { 
     this.BackgroundImage = Properties.Resources.updating1; 
     Stopwatch dw = new Stopwatch(); 
     dw.Start(); 
     bool qsdf = true; 
     while (qsdf) 
     { 
      if (dw.ElapsedMilliseconds >= 3000) qsdf = false; dw.Stop(); 
     }  
     this.BackgroundImage = Properties.Resources.updating2; 
     Stopwatch sw = new Stopwatch(); 
     sw.Start(); 
     qsdf = true; 
     while (qsdf) 
     { 
      if (sw.ElapsedMilliseconds >= 3000) qsdf = false; sw.Stop(); 
     } 
     this.Close(); 

이제 어떤 이유로 든 양식 (Updating이라는 양식)이 표시되지 않습니다. 현재 진행되는 모든 작업은 기본 양식을 표시하고 업데이트 양식을 한 번 보지 못하게하기 전에 (스톱워치에서 언급 한대로) 6 초 동안 아무것도 얻지 못합니다.

주 : 루프가 UI 스레드를 차단

this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 
     this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 
     this.BackgroundImage = global::BossCraftLauncher.Properties.Resources.updating1; 
     this.ClientSize = new System.Drawing.Size(300, 100); 
     this.ControlBox = false; 
     this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; 
     this.MaximizeBox = false; 
     this.MinimizeBox = false; 
     this.Name = "Updating"; 
     this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; 
     this.Text = "BCL Update"; 
     this.Load += new System.EventHandler(this.Updating_Load); 
     this.ResumeLayout(false); 

답변

1

:이 모든 구성 요소를 그립니다 내 Updating.Designer.cs의 코드입니다. 로드 이벤트가 발생하면 루프가 메시지 큐를 계속 중지합니다.

가장 쉬운 방법은 (WinForms를 사용할 때) Timer 컨트롤을 사용하고 코드를 Tick 이벤트에 넣는 것입니다.

+0

나는 그 때 다음과 같이 해보겠습니다. – Yorrick

+0

매력처럼 작동했습니다. :) 적어도 이미지가 올바르게 변경되고 있음을 알고 있습니다. – Yorrick

0

왜 Updating_Load에서 Updating 폼을 닫고 있습니까? "this.Close();" formload에 close() 함수를 작성하면 화면을로드 한 후 양식이 닫힙니다.

+0

초시계가 모두 3 초 (6 초)에 도달 할 때까지 닫히지 않습니다. 총)이므로 문제가되지 않아야합니다. – Yorrick

관련 문제