C# 如何制作循环计时器?
我想用定时器在面板上做时间循环标签,但怎么做? 我得到了这个密码:C# 如何制作循环计时器?,c#,timer,infinite-loop,windows-forms-designer,C#,Timer,Infinite Loop,Windows Forms Designer,我想用定时器在面板上做时间循环标签,但怎么做? 我得到了这个密码: private void Form1_Load(object sender, EventArgs e) { label3.AutoSize = true; label3.Text = label3.Text; label3.Parent = panel1; label3.Location = new Point(panel1.ClientSize.Width, panel1.ClientSize.
private void Form1_Load(object sender, EventArgs e)
{
label3.AutoSize = true;
label3.Text = label3.Text;
label3.Parent = panel1;
label3.Location = new Point(panel1.ClientSize.Width, panel1.ClientSize.Height / 2 - (label3.Height / 2));
timer1.Start();
}
及
private void timer1\u勾选(对象发送方,事件参数e)
{
如果(标签3.Right<0)
{
label3.Text=Convert.ToString(panel1.ClientSize.Width);
}
其他的
{
标签3.左-=10;
}
}
如何创建无限时间循环?在Do…While循环中使用StopWatch类
Stopwatch sw = new Stopwatch();
long time;
sw.Start();
do
{
time = sw.ElapsedMilliseconds;
} while (time < 10000); //ten seconds
Stopwatch sw=新秒表();
长时间;
sw.Start();
做
{
时间=sw.ElapsedMilliseconds;
}时间<10000次//十秒钟
Stopwatch sw = new Stopwatch();
long time;
sw.Start();
do
{
time = sw.ElapsedMilliseconds;
} while (time < 10000); //ten seconds