virtual public void Execute() { while (true) { LogData data; //double check lock (_dataQueue) { if (_dataQueue.Count > 0) { lock (_dataQueue) { data = _dataQueue.Dequeue(); } //判断是否需要打印起始行 if (!_hadLogFiles.Contains(data._type.ToString())) { MyFileStream.WriteFile(_logFileFullPath, data._type.ToString(), string.Format("<-begin line 文件名-数据 {0}->", DateTime.Now.ToString())); _hadLogFiles.Add(data._type.ToString()); } //打印 MyFileStream.WriteFile(_logFileFullPath, data._type.ToString(), data._data); } } } }
/// <summary> /// 输出峰值到peaks文件 /// </summary> /// <param name="_curFullPath"></param> /// <param name="fileFullName"></param> /// <param name="peaks"></param> private void OutPutPeaks(string _curFullPath, string fileFullName, UInt32[] peaks) { if (peaks.Length < 2) { MyFileStream.WriteFile(_curFullPath + "\\数据", "peaks", string.Format("<-start 峰值-文件名-时间-序号 {0};{1}->", DateTime.Now.ToString(), _counter++)); return; } //控制台 Console.WriteLine("文件:{0}\t峰值a:{1} 峰值b:{2}", fileFullName, peaks[0], peaks[1]); //文件 MyFileStream.WriteFile(_curFullPath + "\\数据", "peaks", string.Format("{0} {1}\t{2};\t{3}\t{4}", peaks[0], peaks[1], fileFullName, DateTime.Now.ToString(), _counter++)); }