Skip to content

Commit

Permalink
Check EventSource.IsSupported in code paths specific to thread pool…
Browse files Browse the repository at this point in the history
… worker tracking

Fixes dotnet#47871
  • Loading branch information
kouvel committed Aug 4, 2021
1 parent 9586375 commit affe694
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public static partial class ThreadPool

// This needs to be initialized after UsePortableThreadPool above, as it may depend on UsePortableThreadPool and the
// config initialization
internal static readonly bool EnableWorkerTracking = GetEnableWorkerTracking();
private static readonly bool IsWorkerTrackingEnabledInConfig = GetEnableWorkerTracking();

private static unsafe bool InitializeConfigAndDetermineUsePortableThreadPool()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static partial class ThreadPool
#if CORERT
internal const bool EnableWorkerTracking = false;
#else
internal static readonly bool EnableWorkerTracking =
private static readonly bool IsWorkerTrackingEnabledInConfig =
AppContextConfigHelper.GetBooleanConfig("System.Threading.ThreadPool.EnableWorkerTracking", false);
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1059,6 +1059,8 @@ public static partial class ThreadPool
box.MoveNext();
};

internal static bool EnableWorkerTracking => IsWorkerTrackingEnabledInConfig && EventSource.IsSupported;

[CLSCompliant(false)]
[UnsupportedOSPlatform("browser")]
public static RegisteredWaitHandle RegisterWaitForSingleObject(
Expand Down

0 comments on commit affe694

Please sign in to comment.