public void WriteEvent(SystraceEvent systraceEvent) { Validate.IsNotNull(systraceEvent, nameof(systraceEvent)); lock (this.sync) { if (this.isFirstEvent) { this.textWriter.Write("[ "); } else { this.textWriter.WriteLine(","); this.textWriter.Write(" "); } this.stringBuilder.Clear(); systraceEvent.AppendTo(this.stringBuilder); string eventText = this.stringBuilder.ToString(); this.textWriter.Write(eventText); this.textWriter.Flush(); this.isFirstEvent = false; } }
public void Dispose() { if (this.systraceEvent != null) { this.systraceEvent.EventType = SystraceEventTypes.DurationEnd; this.systraceEvent.TimestampMicroseconds = this.systraceEvent.Session.GetCurrentTimestampMicroseconds(); this.systraceEvent.Session.writer.WriteEvent(this.systraceEvent); this.systraceEvent.Session.stream.Flush(false); this.systraceEvent = null; } }
internal BeginEventScope(SystraceSession session, string name, string categories) { this.systraceEvent = new SystraceEvent( session, name, categories, SystraceEventTypes.DurationBegin, session.GetCurrentTimestampMicroseconds(), session.processID, Thread.CurrentThread.ManagedThreadId); this.systraceEvent.Session.writer.WriteEvent(this.systraceEvent); this.systraceEvent.Session.stream.Flush(false); }