0

如何动态地从文本框中获取数值到数组中? 并将这些值打印在名为“ArrLbl”的标签中,间隔为3秒。动态添加元素到数组

我用Threading.thread,睡觉!但是它的工作原理而已,当我每threading.thread.sleep

Windows窗体应用程序在Visual Studio中后,把MessageBox的2012

我是初学者

帮我请

+0

你不会使用一个循环的。您可以使用“Timer”来创建每个动作之间的时间间隔。 – jmcilhinney 2014-08-30 02:21:54

回答

1

你不想在你的程序中使用的Thread.Sleep因为Thread.sleep代码会从睡眠中停止运行您的程序。它不会响应点击和移动等。你想要的是一个Timer这将让你的程序正常运行,并会在3秒的时间间隔内引发一个事件。

你会做这样的事情:

public class MyFrom : Form { 
    private Timer timer = new Timer(); 

    public MyForm() { 
     timer.Interval = 3000; // The interval is in ms 
     timer.Tick += new TimerTick; 
     timer.Start(); 
    } 

    private void TimerTick(object sender, EventArgs e) { 
     // Get the value from your text boxes here. 
    } 
}