zoukankan      html  css  js  c++  java
  • 添加设备轮询操作

    private IFacilityService facilitySrvA = ServiceLocator.Get<IFacilityService>();
    private IFacilityService facilitySrvB = ServiceLocator.Get<IFacilityService>();

    //需要生成两个代理类实体,不然同一个代理类实体的,两次调用会是按串行化方式进行

    var timer1 = new System.Timers.Timer();
    timer1.Interval = 100;
    timer1.Enabled = false;
    timer1.Elapsed += (s, e) =>
    {
    timer1.Enabled = false;
    var t = facilitySrvA.GetStatus("ZD001");
    Console.WriteLine("GetStatus:" + t +","+ DateTime.Now.ToString());
    timer1.Enabled = true;
    };
    timer1.Start();

    var timer2 = new System.Timers.Timer();
    timer2.Interval = 500;
    timer2.Enabled = false;
    timer2.Elapsed += (s, e) =>
    {
    timer2.Enabled = false;
    Console.WriteLine("触发了:SetIO");
    var t = facilitySrvB.SetIO("ZD001", 12, 1);
    Console.WriteLine("SetIO:" + t +","+ DateTime.Now.ToString());
    timer2.Enabled = true;
    };
    timer2.Start();

    轮询时间需要长点,开始可以设置2秒左右,以减少cpu占用

  • 相关阅读:
    keycloack docker 本地运行
    Windows10 Docker加速
    XenServer创建镜像Storage
    docker gitlab
    mongodb管理
    mongodb基础
    MS SQL Server迁移至Azure SQL(官方工具)
    Centos Nodejs
    ubuntu 16.04 LTS安装jenkins服务器
    Ubuntu Nginx
  • 原文地址:https://www.cnblogs.com/wdfrog/p/5884076.html
Copyright © 2011-2022 走看看