2014-05-22 4 views
-2

창 양식 진행률 표시 줄과 관련하여 문제가 있습니다. Windows 응용 프로그램에서 C#을 사용하여 진행률 표시 줄이 표시되었습니다. 이제 버튼 클릭에 진행률 표시 줄을 표시하고 싶지만 버튼을 클릭하면 완료 될 30 초가 걸리는 업데이트 쿼리가 실행됩니다. 쿼리가 실행되는 동안 진행률 표시 줄. 나는 약간의 코드를 시도하고 있지만 해결책을 찾지 못한다.창 양식에서 진행률 막대를 구현하는 방법

C#을

private void btnGo_Click(object sender, EventArgs e) 
{ 
      DialogResult result = MessageBox.Show("This will update your Website. " + Environment.NewLine + "Are you Sure You want to update the Website?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Information); 
      if (result == DialogResult.Yes) 
      { 
       pgbrUpdate.Visible = true; 
       pgbrUpdate.MarqueeAnimationSpeed = 30; 
       ExecuteQuerry(); 
       pgbrUpdate.Visible = false; 
      } 
} 
+0

가능한 중복 bar?] (http://stackoverflow.com/questions/4499561/c-sharp-how-to-load-a-form-with-marquee-progress-bar) –

+0

진행 상황을 업데이트하려면 백그라운드 작업자를 구성해야합니다. 막대를 실행하는 동안 진행률 표시 줄이 파일되고 쿼리가 끝나면 표시 줄을 사용하지 않도록 설정할 수 있습니다. – Aboca

+0

@DanielKelley가 공유 한 링크를 확인하십시오, 그것에 대한 일부 문서를 참조하십시오 – Aboca

답변

0

이동 새 작업 (또는 스레드)에 UpdateTask와 타이머 일부 진전을 보여

private void btnGo_Click(object sender, EventArgs e) 
{ 
    DialogResult result = MessageBox.Show("This will update your Website. " + 
     Environment.NewLine + "Are you Sure You want to update the Website?", 
     "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Information); 
    if (result == DialogResult.Yes) 
    { 
     updateTimer.Start(); 
     Task.Factory.StartNew(() => ExecuteQuery()); 
    } 
} 

updateTimer_Tick() 
{ 
    updateTimer.Value +=1; 
} 
천막 진행 폼을로드하는 방법 [C 번호의
관련 문제