如何动态地从文本框中获取数组的值? 并在名为" ArrLbl"的标签中打印这些值,间隔为3秒。
我使用了Threading.thread,睡觉了!但是只有当我在每个threading.thread.sleep之后放置MessageBox时它才有效。
Visual Studio 2012中的Windows窗体应用程序
我是初学者
请帮助我答案 0 :(得分: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.
}
}