zoukankan      html  css  js  c++  java
  • ConcurrentDictionary 用法

    using Iot.Model.SklDtos;
    using WindowsTcpip.Server;
    using System;
    using System.Collections.Concurrent;
    using System.Collections.Generic;
    using System.Configuration;
    using System.Diagnostics;
    using System.IO;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using Iot.Dal.Base;
    using Iot.Common;
    using Iot.Model;
    using Newtonsoft.Json;
    using Iot.Factory;
    using Aliyun.MNS.Model;
    using Aliyun.MNS;
    using System.Threading;
    using Iot.Model.BatteryTcpip;
    using Iot.Model.Pagination;
    using Iot.Dal.WA_Device;
    
    namespace SktServer
    {
        class Program
        {
            public static ConcurrentDictionary<int, BatteryOtaModel> OtaList = new ConcurrentDictionary<int, BatteryOtaModel>();
            static void Main(string[] args)
            {
                var otaef = OtaList.Where(A => A.Key == 1).FirstOrDefault();
                if (otaef.Value != null && !string.IsNullOrEmpty(otaef.Value.BatterySn))
                {
                   
                }
                else
                {
                    OtaList.TryAdd(1, new BatteryOtaModel() { BatterySn = "123", OtaNumber = 1 });
                  
                }
                otaef = OtaList.Where(A => A.Key == 1).FirstOrDefault();
                if (otaef.Value != null && !string.IsNullOrEmpty(otaef.Value.BatterySn))
                {
                    otaef.Value.BatterySn = "333";
                    otaef.Value.OtaNumber = 2;
                }
                if (otaef.Value != null && !string.IsNullOrEmpty(otaef.Value.BatterySn))
                {
                    otaef.Value.BatterySn = "444";
                    otaef.Value.OtaNumber = 3;
                }
                var ef = OtaList.Where(A => A.Key == 1).FirstOrDefault();
                BatteryOtaModel mol = new BatteryOtaModel();
                OtaList.TryRemove(1, out mol);
                
                Console.Read();
            }
    
            public class BatteryOtaModel
            {
                public string BatterySn { get; set; }
                public long OtaNumber { get; set; }
            }
        }
    }
  • 相关阅读:
    CSP-S2019游记
    小程序回馈模块,测试陷入泥沼
    送测质量烂的一匹,还要不要继续测试?
    day1 执行用例
    写了人生中第一个完整模块的用例
    项目测试中发现产品bug怎么办
    项目测试操作规范
    idea连接mysql
    自动化环境配置
    linux,无法进行写操作怎么办?read-only file system
  • 原文地址:https://www.cnblogs.com/chenwolong/p/14217619.html
Copyright © 2011-2022 走看看