前提是winform程序要开启运行,timer才会执行。
public TimeSpan fun()
{
System.DateTime currentTime = new System.DateTime();
currentTime = System.DateTime.Now;
DataTable dtMaxTime = BLL.XBC_Record.GetMaxTime();
DateTime historyTime = Convert.ToDateTime(dtMaxTime.Rows[0][0].ToString());
TimeSpan ts = currentTime - historyTime;
return ts;
}
以下有2个定时器:
private void timer2_Tick(object sender, EventArgs e)
{