2021-05-21 仓库温控系统(Winform) 17 定时器的使用

Posted 微软MVP Eleven

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了2021-05-21 仓库温控系统(Winform) 17 定时器的使用相关的知识,希望对你有一定的参考价值。

System.Timers.Timer timer = null;
private void InitStatusInfo()
{
    string uName = this.Tag.ToString();
    lblLoginUser.Text = uName;

    //时间  动态时间条--- 计时器  (Timers.Timer)
    lblLoginTime.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
    timer = new System.Timers.Timer();
    timer.Interval = 1000;
    timer.AutoReset = true;
    timer.Elapsed += Timer_Elapsed;
    timer.Start();
}

private void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
    this.Invoke(new Action(() =>
    {
        this.lblLoginTime.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
    }));
}

以上是关于2021-05-21 仓库温控系统(Winform) 17 定时器的使用的主要内容,如果未能解决你的问题,请参考以下文章