private void SendBuffer() { // start logging to a new file LogFile oldFile; using (var lockmgr = new ReaderWriterLockMgr(_tempFileLock)) { lockmgr.EnterWriteLock(); oldFile = _tempFile; _tempFile = GetTempFile(); } using (oldFile) { // email file if (oldFile.FileInfo.Exists && oldFile.FileInfo.Length > 0) { var subj = Subject ?? string.Format("{0} Log Entries", AppDomain.CurrentDomain.FriendlyName); var body = oldFile.ReadAllText(); Send(subj, body); } // prepare for next period if (Interval == null) return; Interval.Update(); Interval.StartTimer(); } }
private void BufferEntry(LogEntry entry) { using (var lockmgr = new ReaderWriterLockMgr(_tempFileLock)) { lockmgr.EnterReadLock(); var body = GetBody(entry); _tempFile.Append(body); } }