// Singleton controller instance.
private static EventPipeController s_controllerInstance = null;
+ // Initialization flag used to avoid initializing FrameworkEventSource on the startup path.
+ private static bool s_initializing = false;
+
// Controller object state.
private Timer m_timer;
private string m_configFilePath;
private string m_traceFilePath = null;
private bool m_configFileExists = false;
+ internal static bool Initializing
+ {
+ get { return s_initializing; }
+ }
+
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)
}
}
catch { }
+ finally
+ {
+ s_initializing = false;
+ }
}
private EventPipeController()
}
else
{
- if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.ThreadTransfer))
+ // Don't emit this event during EventPipeController. This avoids initializing FrameworkEventSource during start-up which is expensive relative to the rest of start-up.
+ if (!EventPipeController.Initializing && FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.ThreadTransfer))
FrameworkEventSource.Log.ThreadTransferSendObj(this, 1, string.Empty, true, (int)dueTime, (int)period);
success = m_associatedTimerQueue.UpdateTimer(this, dueTime, period);