public static ConcurrentQueue <CjdHeat> QueueWaitingCjdHeats = new ConcurrentQueue <CjdHeat>(); //全局的采集点队列 /// <summary> /// 处理队列内的数据,存入数据库 /// </summary> public static void DealWith() { DataTable dtEndTable = new DataTable(); Task task = new Task(() => { while (true) { while (QueueWaitingCjdHeats.Count > 0) { if (dtEndTable.Rows.Count < 10000) //小于10000则向数据库内插入数据 { CjdHeat heat; QueueWaitingCjdHeats.TryDequeue(out heat); HeatManager.InsertIntoOneHeatIntoTmpTable(heat);//存入Datatable,等待存入数据库 //DicHeatRealTime.TryUpdate(heat.Address, heat, DicHeatRealTime[heat.Address]);//更新实时数据Dic //ListCjdHeats.Add(heat); //出队一个插入待存入列表,用于比对 } else //如果到达10000个,则存储数据库,更新实时数据 { DateTime dtmStart = DateTime.Now; HeatManager.BulkSave2DB(dtEndTable); //CompareAndUpdateRealTimeData(); //ListCjdHeats.Clear(); //把待存入清空 DateTime dtmEnd = DateTime.Now; //Analysis.DblCurSaveTime = (dtmEnd - dtmStart).TotalMilliseconds; //毫秒 //Analysis.DblSaveTotalTime += Analysis.DblCurSaveTime; //Analysis.SaveCounts++; } } } }); task.Start(); }
private void OnEnable() { _heatManager = FindObjectOfType <Player>().HeatManager; if (_heatManager == null) { this.gameObject.SetActive(false); } }
private void Awake() { instance = this; }
// Use this for initialization void Start() { if (instance == null) instance = this; }
void OnEnable() { if (instance != null) throw new System.Exception("Multiple Managers found"); instance = this; this.HeatSourceObjectList = new List<HeatSourceObject>() ; }
void Awake() { heatManager = GetComponentInParent <HeatManager>(); }