Dont expose threads to old .NET

This commit is contained in:
Matt Nadareski
2024-10-24 06:00:31 -04:00
parent 5185dde9a5
commit 29f6771845
3 changed files with 9 additions and 1 deletions

View File

@@ -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;

View File

@@ -16,12 +16,12 @@ namespace SabreTools.Core
/// </summary>
public readonly static string? Version = Assembly.GetExecutingAssembly().GetName().Version?.ToString();
#if NET452_OR_GREATER || NETCOREAPP
/// <summary>
/// Maximum threads to use during parallel operations
/// </summary>
public static int MaxThreads { get; set; } = Environment.ProcessorCount;
#if NET452_OR_GREATER || NETCOREAPP
/// <summary>
/// ParallelOptions object for use in parallel operations
/// </summary>

View File

@@ -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
}
/// <summary>
@@ -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)