顯示一個旋轉輪進度動畫GIF,而用戶啓動一個長時間運行的過程。 當我點擊開始,過程開始,同一時間輪開始旋轉。C#,winform - Spining輪子進度中斷並間歇性地恢復
但問題是,輪子在中間和繼續,在長期過程中發生多次。它應該是連續旋轉的。我在同一個線程中運行任務和動畫gif(,因爲指標只是一個動畫圖像,不是真實的進度值)。使用
守則,
this.progressPictureBox.Visible = true;
this.Refresh(); // this - an user controll
this.progressPictureBox.Refresh();
Application.DoEvents();
OnStartCalibration(); // Starts long running process
this.progressPictureBox.Visible = false;
OnStartCalibration()
{
int count = 6;
int sleepInterval = 5000;
bool success = false;
for (int i = 0; i < count; i++)
{
Application.DoEvents();
m_keywordList.Clear();
m_keywordList.Add("HeatCoolModeStatus");
m_role.ReadValueForKeys(m_keywordList, null, null);
l_currentValue = (int)m_role.GetValue("HeatCoolModeStatus");
if (l_currentValue == 16)
{
success = true;
break;
}
System.Threading.Thread.Sleep(sleepInterval);
}
}
如何顯示輪的未interepted連續顯示,直到進程結束?
請貼在你是如何處理長期運行過程.. BackgroundWorker的一些代碼? BeginInvoke的? – 2012-03-16 06:46:47