Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/283.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何制作循环计时器?_C#_Timer_Infinite Loop_Windows Forms Designer - Fatal编程技术网

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