【发布时间】:2012-03-16 06:43:38
【问题描述】:
在用户启动长时间运行的过程时显示旋转轮进度动画 gif。 当我单击开始时,该过程开始并且同时轮开始旋转。
但问题是,轮子在中间撞击并恢复,在长期过程中会发生多次。它应该是连续旋转的。我在同一个线程中同时运行任务和动画 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);
}
}
如何在流程结束之前不间断地连续显示车轮?
【问题讨论】:
-
请发布一些关于您如何处理长时间运行的进程的代码。BackgroundWorker?开始调用?
标签: c# activity-indicator