Ejemplo n.º 1
0
        public static void Monitor()
        {
            try
            {
                string data = string.Empty;
                string key  = string.Empty;
                while (true)
                {
                    if (cts.Token.IsCancellationRequested)
                    {
                        break;
                    }

                    int i = 0;
                    while (i++ < PostParams.P_I.iCycTimes && CIM.GetListCnt() > 0)
                    {
                        Log.L_I.WriteError("MCMQ", string.Format("开始第{0}次扫描,当前待Recv数量:{1}", i, CIM.GetListCnt()));

                        Thread.Sleep(200);
                        if (CIM.C_I.ReadData(out data, out key) == CIM.ReturnOK)
                        {
                            CIM.AddDic(key, XMLHelpler.ParseStr(data, key, out PostType type));
                            Log.L_I.WriteError("MCMQ", "ADD" + key);
                            CIM.RemoveIDFromList(key);
                            i = 0;
                        }
                    }
                    if (CIM.GetListCnt() > 5)
                    {
                        DataFlowAlarm_event?.Invoke();
                    }
                    //Log.L_I.WriteError("MCMQ", "Finish Monitor " + key);
                    Thread.Sleep(100);
                }
            }
            catch (Exception ex)
            {
                Log.L_I.WriteError(ClassName, ex);
            }
        }