예제 #1
0
 private void UpdateXmlLog()
 {
     if (Settings.Default.WriteLogToDisk)
     {
         var xml = new XmlSerializer(typeof(List <PerformanceState>));
         using (var stream = File.Open(_logFileName, FileMode.OpenOrCreate)) {
             xml.Serialize(stream, PerformanceStateList.ToList());
         }
     }
 }
예제 #2
0
        private void UpdateGuiLogPreview(PerformanceState state)
        {
            PerformanceStateList.Add(state);

            if (PerformanceStateList.Count > 50 && PerformanceStateList.Count > _measurementTimeInterval)
            {
                // keep the GUI list small
                PerformanceStateList.RemoveAt(0);
            }
        }
예제 #3
0
        private void InitLogMessages()
        {
            if (File.Exists(_logFileName))
            {
                try {
                    var xml = new XmlSerializer(typeof(List <PerformanceState>));
                    List <PerformanceState> list;
                    using (var stream = File.OpenRead(_logFileName)) {
                        list = xml.Deserialize(stream) as List <PerformanceState>;
                    }

                    // last 50 entrys
                    foreach (var entry in list.Skip(Math.Max(0, PerformanceStateList.Count() - 50)))
                    {
                        PerformanceStateList.Add(entry);
                    }
                }
                catch {
                    File.Move(_logFileName, DateTime.Now.ToFileTimeUtc() + "-BrokenLogFile.xml");
                }
            }
        }