组件--Timer属性设置
Enabled=True; 是否启用
Interval=1000;间隔时间
private void time_Tick(object sender, EventArgs e){
//time.Tick += new EventHandler(time_Tick); //委托事件
this.sj.Text = DateTime.Now.ToString(); //赋值操作
//time.Start(); //再次启用
Enabled=True; 是否启用
Interval=1000;间隔时间
private void time_Tick(object sender, EventArgs e){
//time.Tick += new EventHandler(time_Tick); //委托事件
this.sj.Text = DateTime.Now.ToString(); //赋值操作
//time.Start(); //再次启用
}
死循环更新时间--容易出现内存泄漏
while(true){
this.sj.Text = DateTime.Now.ToString(); //赋值操作
Application.DoEvents(); //处理所有的当前在消息队列中的Windows消息。
System.Threading.Thread.Sleep(1000); //当前线程休息1000毫秒(1秒)
}
第一次发,
timer Tick事件两行代码可以省略
理解意思就行,记录常用的事件(备忘)