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. 
    } 
}