今天刚学了winforms的timer控件,写了简单的运用timer控件的程序
long timeStart;
private void Form1_Load(object sender, System.EventArgs e)
{
timeStart=System.Environment.TickCount;
this.timer1 .Enabled =true;
this.timer1 .Interval =1000;
}
TimeSpan timeSpan;
private void timer1_Tick(object sender, System.EventArgs e)
{
long current=System.Environment.TickCount;
timeSpan=new TimeSpan (current*10*1000);
this.label1 .Text ="本计算机启动时间:"+timeSpan.ToString ();
timeSpan=new TimeSpan((current-timeStart)*10*1000);
this.label2.Text ="程序运行时间:"+timeSpan.ToString ();
this.label3.Text ="当前时间:"+DateTime.Now.ToString();
}