[release/8.0] Add boolean field to indicate whether or not the Windows thread pool...
authorgithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Tue, 29 Aug 2023 23:36:57 +0000 (16:36 -0700)
committerGitHub <noreply@github.com>
Tue, 29 Aug 2023 23:36:57 +0000 (16:36 -0700)
* Add boolean field to indicate whether or not the Windows thread pool is being used

* Update src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.Windows.cs

Co-authored-by: Stephen Toub <stoub@microsoft.com>
* Remove trailing spaces

* Move comment

* Update fields and comments

* Disable CA1823 - unused field

---------

Co-authored-by: unknown <eduardo.velarde@pucp.pe>
Co-authored-by: Eduardo Velarde <32459232+eduardo-vp@users.noreply.github.com>
Co-authored-by: Stephen Toub <stoub@microsoft.com>
src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.Windows.cs

index 6882b04..0da8754 100644 (file)
@@ -13,6 +13,12 @@ namespace System.Threading
         internal static bool UseWindowsThreadPool { get; } =
             AppContextConfigHelper.GetBooleanConfig("System.Threading.ThreadPool.UseWindowsThreadPool", "DOTNET_ThreadPool_UseWindowsThreadPool");
 
+#pragma warning disable CA1823
+        // The field should reflect what the property returns because the property can be stubbed by trimming,
+        // such that sos reflects the actual state of what thread pool is being used and not just the config value.
+        private static readonly bool s_useWindowsThreadPool = UseWindowsThreadPool; // Name relied on by sos
+#pragma warning restore CA1823
+
 #if NATIVEAOT
         private const bool IsWorkerTrackingEnabledInConfig = false;
 #else