static void RunTest()
        {
            var tmfDirectory = ".";
            var sessionName  = "My Real Time Session";

            TraceEventSession   session = null;
            ETWTraceEventSource source  = null;
            bool started = false;
            // Start a thread to listen for incoming events in real time.
            var listenThread = new System.Threading.Thread(delegate()
            {
                using (session = new TraceEventSession(sessionName, null))
                {
                    session.StopOnDispose = true;
                    using (source = new ETWTraceEventSource(sessionName, TraceEventSourceType.Session))
                    {
                        session.EnableProvider(WPPProviderGuid1, (TraceEventLevel)200, ulong.MaxValue);
                        session.EnableProvider(WPPProviderGuid2, (TraceEventLevel)200, ulong.MaxValue);

                        started = true;
                        // This is my callback.  Right now I just print.
                        Action <TraceEvent> print = delegate(TraceEvent data) { Console.WriteLine(data.ToString()); };

                        // Wire up callbacks
#if false                                                    // Other parsers you could enable
                        var dynamicParser = source.Dynamic;  // EventSources
                        dynamicParser.ReadAllManifests("."); // If we have explicit manifests we wish to use (but not register with the OS).
                        dynamicParser.All += print;

                        var registeredParser  = new RegisteredTraceEventParser(source);     // OS build in events
                        registeredParser.All += print;
#endif
                        var wppParser  = new WppTraceEventParser(source, tmfDirectory);     // WPP where we have the TMF files in 'tmfDirectory'
                        wppParser.All += print;

                        source.UnhandledEvent += print; // Optional.  Shows events you don't recognize.  probably worth investigating.
                        source.Process();               // listen for incomming events.
                    }
                }
            });

            // Wait for startup
            while (!started)
            {
                System.Threading.Thread.Sleep(1);
            }

            Console.WriteLine("Listening for 1 min");
            System.Threading.Thread.Sleep(60000);

            // To stop listening
            Console.WriteLine("Stopping listening");
            source.StopProcessing();
            source.Dispose();
            session.Dispose();

            Console.WriteLine("Done");
        }
        static void RunTest()
        {
            var tmfDirectory = ".";
            var sessionName = "My Real Time Session";

            TraceEventSession session = null;
            ETWTraceEventSource source = null;
            bool started = false;
            // Start a thread to listen for incoming events in real time. 
            var listenThread = new System.Threading.Thread(delegate()
            {
                using (session = new TraceEventSession(sessionName, null))
                {
                    session.StopOnDispose = true;
                    using (source = new ETWTraceEventSource(sessionName, TraceEventSourceType.Session))
                    {
                        session.EnableProvider(WPPProviderGuid1, (TraceEventLevel)200, ulong.MaxValue);
                        session.EnableProvider(WPPProviderGuid2, (TraceEventLevel)200, ulong.MaxValue);

                        started = true;
                        // This is my callback.  Right now I just print.  
                        Action<TraceEvent> print = delegate(TraceEvent data) { Console.WriteLine(data.ToString()); };

                        // Wire up callbacks 
#if false               // Other parsers you could enable
                        var dynamicParser = source.Dynamic;         // EventSources
                        dynamicParser.ReadAllManifests(".");        // If we have explicit manifests we wish to use (but not register with the OS).  
                        dynamicParser.All += print;   

                        var registeredParser = new RegisteredTraceEventParser(source);      // OS build in events
                        registeredParser.All += print;
#endif
                        var wppParser = new WppTraceEventParser(source, tmfDirectory);      // WPP where we have the TMF files in 'tmfDirectory'
                        wppParser.All += print;

                        source.UnhandledEvent += print;     // Optional.  Shows events you don't recognize.  probably worth investigating. 
                        source.Process();   // listen for incomming events. 
                    }
                }
            });

            // Wait for startup
            while (!started)
                System.Threading.Thread.Sleep(1);

            Console.WriteLine("Listening for 1 min");
            System.Threading.Thread.Sleep(60000);

            // To stop listening
            Console.WriteLine("Stopping listening");
            source.StopProcessing();
            source.Dispose();
            session.Dispose();

            Console.WriteLine("Done");
        }