进度条运行时间少于定义的时间 [英] Progress Bar run less time than defined
本文介绍了进度条运行时间少于定义的时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建了一个获取毫秒数然后运行进度条的函数,但结果是进度条的运行时间比定义的要少.
I created a function that gets number of milliseconds and then runs the progress bar but the result is that the progress bar run less time than defined.
this.timerProgress.Tick += new System.EventHandler(this.timerProgress_Tick);
public void AnimateProgBar(int milliSeconds)
{
if (!timerProgress.Enabled)
{
this.Invoke((MethodInvoker)delegate { pbStatus.Value = 0; });
timerProgress.Interval = milliSeconds / 100;
timerProgress.Enabled = true;
}
}
private void timerProgress_Tick(object sender, EventArgs e)
{
if (pbStatus.Value < 100)
{
pbStatus.Value += 1;
pbStatus.Refresh();
}
else
{
timerProgress.Enabled = false;
}
}
推荐答案
调用 AnimateProgBar(1000)
将导致以下计算:1000/100
.这等于 10
.
A call to AnimateProgBar(1000)
will result in the following calculation: 1000 / 100
. That equals 10
.
Timer
间隔已经以毫秒为单位.因此,您有效地将间隔设置为 10ms
.
The Timer
interval is already in milliseconds. So you're effectively setting the interval to 10ms
.
这篇关于进度条运行时间少于定义的时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文