From 29f677184546bcd2e1955fbd79f426cd46e26ade Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Thu, 24 Oct 2024 06:00:31 -0400 Subject: [PATCH] Dont expose threads to old .NET --- RombaSharp/Features/BaseFeature.cs | 2 ++ SabreTools.Core/Globals.cs | 2 +- SabreTools/Features/BaseFeature.cs | 6 ++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/RombaSharp/Features/BaseFeature.cs b/RombaSharp/Features/BaseFeature.cs index 403f7ae0..9956b652 100644 --- a/RombaSharp/Features/BaseFeature.cs +++ b/RombaSharp/Features/BaseFeature.cs @@ -763,7 +763,9 @@ CREATE TABLE IF NOT EXISTS dat ( port = 65535; // Finally set all of the fields +#if NET452_OR_GREATER || NETCOREAPP Globals.MaxThreads = workers; +#endif _logdir = logdir; _tmpdir = tmpdir; _webdir = webdir; diff --git a/SabreTools.Core/Globals.cs b/SabreTools.Core/Globals.cs index 4cf91fea..ac4d060d 100644 --- a/SabreTools.Core/Globals.cs +++ b/SabreTools.Core/Globals.cs @@ -16,12 +16,12 @@ namespace SabreTools.Core /// public readonly static string? Version = Assembly.GetExecutingAssembly().GetName().Version?.ToString(); +#if NET452_OR_GREATER || NETCOREAPP /// /// Maximum threads to use during parallel operations /// public static int MaxThreads { get; set; } = Environment.ProcessorCount; -#if NET452_OR_GREATER || NETCOREAPP /// /// ParallelOptions object for use in parallel operations /// diff --git a/SabreTools/Features/BaseFeature.cs b/SabreTools/Features/BaseFeature.cs index 16cba3ef..ee082632 100644 --- a/SabreTools/Features/BaseFeature.cs +++ b/SabreTools/Features/BaseFeature.cs @@ -1150,6 +1150,7 @@ namespace SabreTools.Features } } +#if NET452_OR_GREATER || NETCOREAPP internal const string ThreadsInt32Value = "threads"; internal static Feature ThreadsInt32Input { @@ -1163,6 +1164,7 @@ namespace SabreTools.Features longDescription: "Optionally, set the number of threads to use for the multithreaded operations. The default is the number of available machine threads; -1 means unlimited threads created."); } } +#endif #endregion @@ -1812,7 +1814,9 @@ Some special strings that can be used: { AddFeature(ScriptFlag); AddFeature(LogLevelStringInput); +#if NET452_OR_GREATER || NETCOREAPP AddFeature(ThreadsInt32Input); +#endif } /// @@ -1886,8 +1890,10 @@ Some special strings that can be used: Splitter = GetSplitter(features); // Set threading flag, if necessary +#if NET452_OR_GREATER || NETCOREAPP if (features.ContainsKey(ThreadsInt32Value)) Globals.MaxThreads = GetInt32(features, ThreadsInt32Value); +#endif // Failure conditions if (Header == null)