static void JournalHandler_JournalEntryAdded(object sender, JournalEntryAddedEventArgs e) { UpdateInstance(defaultInstance, e); List <int> removeList = new List <int>(); lock (instanceList.SyncRoot) { foreach (KeyValuePair <int, Instance> pair in instanceList) { if (pair.Value.Thread.IsAlive) { UpdateInstance(pair.Value, e); } else { removeList.Add(pair.Key); } } } for (int i = 0; i < removeList.Count; i++) { instanceList.Remove(removeList[i]); } try { entryAddedEvent.Invoke(null, e); } catch (Exception ex) { System.Diagnostics.Trace.WriteLine("Unhandled exception in Journal.LineAdded event. Details:\n" + ex.ToString(), "Error"); } }
private static void UpdateInstance(Instance instance, JournalEntryAddedEventArgs e) { lock (instance.SyncRoot) { instance.History.Add(e.Entry); if (instance.History.Count >= MaxLenght) { instance.History.RemoveAt(0); instance.LineOffset++; } } }
void JournalHandler_JournalEntryAdded(object sender, JournalEntryAddedEventArgs e) { ushort color = 0; if (DataFiles.Hues != null && e.Entry.Color > DataFiles.Hues.MinIndex && e.Entry.Color < DataFiles.Hues.MaxIndex) { color = DataFiles.Hues[e.Entry.Color].Colors[24]; } string line = String.Format("[{0:X}.{1:X}:{2:00}:{3:00}:{4:00} {5:X4}] {6}", e.Entry.TimeStamp.Year - 2000, e.Entry.TimeStamp.DayOfYear, e.Entry.TimeStamp.Hour, e.Entry.TimeStamp.Minute, e.Entry.TimeStamp.Second, color, e.Entry); lock (syncRoot) { if (writer != null) { writer.WriteLine(line); } } }