static void AutoSave(string file, int interval) { while (!stopping) { Thread.Sleep(interval); try { lock (counters) { InstrumentationServiceData data = new InstrumentationServiceData(); data.EndTime = DateTime.Now; data.StartTime = StartTime; data.Counters = counters; data.Categories = categories; FilePath path = file + ".tmp"; using (Stream fs = File.OpenWrite(path)) { BinaryFormatter f = new BinaryFormatter(); f.Serialize(fs, data); } FileService.SystemRename(path, file); } } catch (Exception ex) { LoggingService.LogError("Instrumentation service data could not be saved", ex); } } autoSaveThread = null; }
static void AutoSave (string file, int interval) { while (!stopping) { Thread.Sleep (interval); try { lock (counters) { InstrumentationServiceData data = new InstrumentationServiceData (); data.EndTime = DateTime.Now; data.StartTime = StartTime; data.Counters = counters; data.Categories = categories; FilePath path = file + ".tmp"; using (Stream fs = File.OpenWrite (path)) { BinaryFormatter f = new BinaryFormatter (); f.Serialize (fs, data); } FileService.SystemRename (path, file); } } catch (Exception ex) { LoggingService.LogError ("Instrumentation service data could not be saved", ex); } } autoSaveThread = null; }