internal static void Initialize() { // Don't allow failures to propagate upstream. Ensure program correctness without tracing. try { Initializing = true; if (s_controllerInstance == null) { int enabled = Config_EnableEventPipe; if (enabled > 0) { // Enable tracing immediately. // It will be disabled automatically on shutdown. EventPipe.Enable(BuildConfigFromEnvironment()); } // If not set at all, we listen for changes in the control file. else if (enabled != 0) { // Create a new controller to listen for commands. s_controllerInstance = new EventPipeController(); } // If enable is explicitly set to 0, then don't start the controller (to avoid overhead). RuntimeEventSource.Initialize(); } } catch { } finally { Initializing = false; } }
internal static void Initialize() { // Don't allow failures to propagate upstream. Ensure program correctness without tracing. try { s_initializing = true; if (s_controllerInstance == null) { if (Config_EnableEventPipe > 0) { // Enable tracing immediately. // It will be disabled automatically on shutdown. EventPipe.Enable(BuildConfigFromEnvironment()); } else { // Create a new controller to listen for commands. s_controllerInstance = new EventPipeController(); } } } catch { } finally { s_initializing = false; } }
private void PollForTracingCommand(object state) { // Make sure that any transient errors don't cause the listener thread to exit. try { // Perform initialization when the timer fires for the first time. if (m_traceFilePath == null) { // Set file paths. m_traceFilePath = GetDisambiguatedTraceFilePath(Config_EventPipeOutputFile); m_markerFilePath = MarkerFilePath; // Marker file is assumed to not exist. // This will be updated when the monitoring thread starts. m_markerFileExists = false; } // Check for existence of the file. // If the existence of the file has changed since the last time we checked // this means that we need to act on that change. bool fileExists = File.Exists(m_markerFilePath); if (m_markerFileExists != fileExists) { // Save the result. m_markerFileExists = fileExists; // Take the appropriate action. if (fileExists) { // Enable tracing. EventPipe.Enable(GetConfiguration()); } else { // Disable tracing. EventPipe.Disable(); } } // Schedule the timer to run again. m_timer.Change(fileExists ? EnabledPollingIntervalMilliseconds : DisabledPollingIntervalMilliseconds, Timeout.Infinite); } catch { } }
internal static void Initialize() { // Don't allow failures to propagate upstream. Ensure program correctness without tracing. try { if (!IsControllerInitialized) { if (Config_EnableEventPipe > 0) { // Enable tracing immediately. // It will be disabled automatically on shutdown. EventPipe.Enable(BuildConfigFromEnvironment()); } RuntimeEventSource.Initialize(); IsControllerInitialized = true; } } catch { } }
private void PollForTracingCommand(object state) { // Make sure that any transient errors don't cause the listener thread to exit. try { // Check for existence of the config file. // If the existence of the file has changed since the last time we checked or the update time has changed // this means that we need to act on that change. bool fileExists = File.Exists(m_configFilePath); if (m_configFileExists != fileExists) { // Save the result. m_configFileExists = fileExists; // Take the appropriate action. if (fileExists) { // Enable tracing. // Check for null here because it's possible that the configuration contains a process filter // that doesn't match the current process. IF this occurs, we should't enable tracing. EventPipeConfiguration config = BuildConfigFromFile(m_configFilePath); if (config != null) { EventPipe.Enable(config); } } else { // Disable tracing. EventPipe.Disable(); } } // Schedule the timer to run again. m_timer.Change(fileExists ? EnabledPollingIntervalMilliseconds : DisabledPollingIntervalMilliseconds, Timeout.Infinite); } catch { } }
internal static void Initialize() { // Don't allow failures to propagate upstream. // Instead, ensure program correctness without tracing. try { if (s_controllerInstance == null) { if (Config_EnableEventPipe == 4) { // Create a new controller to listen for commands. s_controllerInstance = new EventPipeController(); } else if (Config_EnableEventPipe > 0) { // Enable tracing immediately. // It will be disabled automatically on shutdown. EventPipe.Enable(GetConfiguration()); } } } catch { } }