163  
查询码:00000204
简单的定时器
作者: 孙强 于 2019年12月26日 发布在分类 / 人防组 / 人防智能化 下,并于 2019年12月26日 编辑
定时器 定时

引言:在现场对接OPC协议设备的时候,采集端数据推送速度太快,时间紧急,想了个折中的法子,简单的定时器





public void Time()
        {
            System.Timers.Timer timer = new System.Timers.Timer();
            timer.Enabled = true;
            timer.Interval = Convert.ToInt32(ConfigurationManager.AppSettings["Time"]) * 1000;//执行间隔时间,单位为毫秒  
            timer.Start();
            timer.Elapsed += new System.Timers.ElapsedEventHandler(Timer1_Elapsed);
        }

        private void Timer1_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            //方法
        }

总结:C#自带的简单的定时功能,简单暴力省事好用。




 推荐知识

 历史版本

修改日期 修改人 备注
2019-12-26 14:17:24[当前版本] 孙强 1.0

知识分享平台 -V 4.8.7 -wcp