public static void ProcessTraces(Guid providerGuid, string sessionName, EtwTraceLevel level, long keyword) { using (var listener = new EventRealtimeListener(providerGuid, sessionName, level, keyword)) { listener.ProcessTraces(); } }
private void UpdateEtwEvents() { DisposeEtwEvents(); if (!_state.EtwStarted) { return; } foreach (EtwProvider provider in App.Current.Settings.EtwProviders) { _etwListeners.TryGetValue(provider.Guid, out EventRealtimeListener listener); if (listener == null) { if (!provider.IsActive) { continue; } // this would be a serialization bug if (provider.Guid == Guid.Empty) { continue; } var level = (EtwTraceLevel)provider.TraceLevel; listener = new EventRealtimeListener(provider.Guid, provider.Guid.ToString(), level); listener.Description = provider.Description; listener.StringMessageMode = provider.StringMessageMode; var t = new Thread(ProcessEtwTrace); t.Start(listener); listener.RealtimeEvent += OnEtwListenerRealtimeEvent; _etwListeners.Add(provider.Guid, listener); } else { if (!provider.IsActive) { listener.RealtimeEvent -= OnEtwListenerRealtimeEvent; listener.Dispose(); _etwListeners.Remove(provider.Guid); continue; } else { listener.Description = provider.Description; listener.StringMessageMode = provider.StringMessageMode; } } } }
private void UpdateEtwEvents() { DisposeEtwEvents(); if (!_settings.CaptureEtwTraces) { return; } foreach (EtwProvider provider in _settings.EtwProviders) { EventRealtimeListener listener; _etwListeners.TryGetValue(provider.ProviderGuid, out listener); if (listener == null) { if (!provider.Active) { continue; } // this would be a serialization bug if (provider.ProviderGuid == Guid.Empty) { continue; } EtwTraceLevel level = (EtwTraceLevel)provider.TraceLevel; listener = new EventRealtimeListener(provider.ProviderGuid, provider.ProviderGuid.ToString(), level); listener.Description = provider.Description; Thread t = new Thread(ProcessEtwTrace); t.Start(listener); listener.RealtimeEvent += OnEtwListenerRealtimeEvent; _etwListeners.Add(provider.ProviderGuid, listener); } else { if (!provider.Active) { listener.RealtimeEvent -= OnEtwListenerRealtimeEvent; listener.Dispose(); _etwListeners.Remove(provider.ProviderGuid); continue; } } } }
private void OnEtwListenerRealtimeEvent(object sender, RealtimeEventArgs e) { EventRealtimeListener listener = (EventRealtimeListener)sender; Enqueue(e.ProcessId, e.Message, listener.Description); }
private void ProcessEtwTrace(object state) { EventRealtimeListener listener = (EventRealtimeListener)state; listener.ProcessTraces(); }
private void UpdateEtwEvents() { DisposeEtwEvents(); if (!_settings.CaptureEtwTraces) return; foreach (EtwProvider provider in _settings.EtwProviders) { EventRealtimeListener listener; _etwListeners.TryGetValue(provider.ProviderGuid, out listener); if (listener == null) { if (!provider.Active) continue; // this would be a serialization bug if (provider.ProviderGuid == Guid.Empty) continue; EtwTraceLevel level = (EtwTraceLevel)provider.TraceLevel; listener = new EventRealtimeListener(provider.ProviderGuid, provider.ProviderGuid.ToString(), level); listener.Description = provider.Description; Thread t = new Thread(ProcessEtwTrace); t.Start(listener); listener.RealtimeEvent += OnEtwListenerRealtimeEvent; _etwListeners.Add(provider.ProviderGuid, listener); } else { if (!provider.Active) { listener.RealtimeEvent -= OnEtwListenerRealtimeEvent; listener.Dispose(); _etwListeners.Remove(provider.ProviderGuid); continue; } } } }