public void Process() { List <LogThreadHelper.LogEntry> queuedLogs = this.m_queuedLogs; lock (queuedLogs) { using (List <LogThreadHelper.LogEntry> .Enumerator enumerator = this.m_queuedLogs.GetEnumerator()) { while (enumerator.MoveNext()) { LogThreadHelper.LogEntry current = enumerator.get_Current(); switch (current.Level) { case LogLevel.Info: this.m_logSource.LogInfo(current.Message); continue; case LogLevel.Warning: this.m_logSource.LogWarning(current.Message); continue; case LogLevel.Error: this.m_logSource.LogError(current.Message); continue; } this.m_logSource.LogDebug(current.Message); } } this.m_queuedLogs.Clear(); } }
private void LogMessage(string message, LogLevel level) { object mQueuedLogs = this.m_queuedLogs; Monitor.Enter(mQueuedLogs); try { List <LogThreadHelper.LogEntry> logEntries = this.m_queuedLogs; LogThreadHelper.LogEntry logEntry = new LogThreadHelper.LogEntry() { Message = message, Level = level }; logEntries.Add(logEntry); } finally { Monitor.Exit(mQueuedLogs); } }