private static void Main(string[] args) { using (MyEventListener myListener = new MyEventListener()) using (MyEventSource source = new MyEventSource()) { myListener.EnableEvents(source, EventLevel.Verbose); if (source.ConstructionException != null) { throw source.ConstructionException; } source.String("Hello world"); source.Int(10); source.Bool(true); } }
private static void Main(string[] args) { string sessionName = "mySession"; using (MyEventSource source = new MyEventSource()) using (TraceEventSession session = new TraceEventSession(sessionName, null)) // the null second parameter means 'real time session' using (ETWTraceEventSource eventSource = new ETWTraceEventSource(sessionName, TraceEventSourceType.Session)) { DynamicTraceEventParser parser = new DynamicTraceEventParser(eventSource); parser.All += delegate(TraceEvent data) { Console.WriteLine("Event name:{0}. Payload:{1}.", data.EventName, data.PayloadValue(0)); }; session.EnableProvider(source.Guid); source.String("Hello world"); source.Int(123); eventSource.Process(); } }