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占用

  • 相关阅读:
    I-Cache和D-cache
    socat使用
    反射
    属性方法
    getitem
    文件打开编辑和函数参数
    python3编码问题个人理解
    正文内容 python3编码问题
    进度条制作
    集合关系
  • 原文地址:https://www.cnblogs.com/wdfrog/p/5884076.html
Copyright © 2011-2022 走看看