111,129
社区成员
发帖
与我相关
我的任务
分享
public partial class Form1 : Form
{
private System.Timers.Timer _timer;
public Form1()
{
InitializeComponent();
_timer = new System.Timers.Timer(2000);
_timer.Elapsed += new ElapsedEventHandler(ProcessElapsedEvent);
_timer.Start();
}
private void ProcessElapsedEvent(object sender, ElapsedEventArgs e)
{
this.textBox1.BeginInvoke(new InsertTextCallback(InsertText), new object[] { "Timer elapse." });
}
private delegate void InsertTextCallback(string text);
private void InsertText(string text)
{
this.textBox1.Text += text + Environment.NewLine;
}
}