/// <summary>将一个待处理的机号存入缓存队列中,并返回队列中的数量 /// /// </summary> /// <returns></returns> public static int SetVin(string vin, out string err) { if (sns.Contains(vin)) { err = "机号" + vin + "已在缓存队列中存在"; return(sns.Count); } sns.Enqueue(vin); CacheJHCountChanged?.Invoke(); err = ""; return(sns.Count); }
/// <summary>尝试从缓冲队列中取出一个有效的机号信息,否则返回null /// /// </summary> /// <returns></returns> public static VinMsg GetVin() { //var sw = System.Diagnostics.Stopwatch.StartNew(); while (sns.Count > 0) { //System.Diagnostics.Trace.WriteLine(sw.ElapsedMilliseconds.ToString()); VinMsg vinmsg = VinMsg.Create(sns.Dequeue(), out string err); CacheJHCountChanged?.Invoke(); //System.Diagnostics.Trace.WriteLine(sw.ElapsedMilliseconds.ToString()); if (err == "") { return(vinmsg); } } //System.Diagnostics.Trace.WriteLine(sw.ElapsedMilliseconds.ToString()); return(null); }
/// <summary>清除所有缓存的机号和当前正在操作的机号 /// /// </summary> /// <returns></returns> public static void ClearAll() { sns.Clear(); CacheJHCountChanged?.Invoke(); }