public void RecordLog(LogType type, string msg) { LogQueueStruct log = new LogQueueStruct() { info = LogCommon.GetLog(type), Msg = msg }; lock (lockobj) { LogList.Enqueue(log); } timer.Change(0, Timeout.Infinite); }
public void RegiestLog() { //开启一个线程用以将队列中的日志记录到文件 tc = new TimerCallback((o) => { timer.Change(Timeout.Infinite, Timeout.Infinite); lock (lockobj) { if (LogList.Count > 0) { LogQueueStruct log = LogList.Dequeue(); LogCommon.WriteLineToTimeFile(log.Msg, log.info, LogPath); } } }); timer = new Timer(tc, null, Timeout.Infinite, Timeout.Infinite); }