110,536
社区成员
发帖
与我相关
我的任务
分享
string GetTickCount()
{
int result = Environment.TickCount & Int32.MaxValue;
TimeSpan tmp = new TimeSpan(Convert.ToInt64(Convert.ToInt64(result) * 10000));
//string workTime = tmp.Days + " 天 " + tmp.Hours + " 时 " + tmp.Minutes + " 分 " + tmp.Seconds + " 秒";
string workTime = string.Format("{0:00}", tmp.Days) + " 天 " + string.Format("{0:00}", tmp.Hours) + " 时 " + string.Format("{0:00}", tmp.Minutes) + " 分 " + string.Format("{0:00}", tmp.Seconds) + " 秒";
return workTime;
}
//窗体的Load里面:
private void LoginUI_Load(object sender, EventArgs e)
{
MethodInvoker mi = new MethodInvoker(delegate { lblMsg.Text = "电脑已工作------:" + Helper.GetTickCount(); });
timer1 = new System.Timers.Timer();
timer1.Interval = 1000;
timer1.Enabled = true;
GC.Collect()
timer1.Elapsed += delegate
{
this.lblMsg.Invoke(mi);
GC.Collect();
};
}