Instruct parallel foreach to not go over the number of processor threads, it's counter productive.

And it should not do it by default but apparently, it does.
This commit is contained in:
2025-07-29 21:36:36 +01:00
parent 2382187960
commit cb4511c09d
3 changed files with 28 additions and 0 deletions

View File

@@ -202,6 +202,10 @@ public partial class ImportRoms : ComponentBase
_stopwatch.Restart();
Parallel.ForEach(_rootImporter.Files,
new ParallelOptions
{
MaxDegreeOfParallelism = Environment.ProcessorCount
},
file =>
{
_ = InvokeAsync(() =>
@@ -284,6 +288,10 @@ public partial class ImportRoms : ComponentBase
// For each archive
Parallel.ForEach(_rootImporter.Archives,
new ParallelOptions
{
MaxDegreeOfParallelism = Environment.ProcessorCount
},
archive =>
{
_ = InvokeAsync(() =>

View File

@@ -99,6 +99,10 @@ public sealed class FileImporter
ConcurrentBag<string> archives = [];
Parallel.ForEach(Files,
new ParallelOptions
{
MaxDegreeOfParallelism = Environment.ProcessorCount
},
file =>
{
SetProgress?.Invoke(this,
@@ -170,6 +174,10 @@ public sealed class FileImporter
ConcurrentBag<string> archives = [];
Parallel.ForEach(Files,
new ParallelOptions
{
MaxDegreeOfParallelism = Environment.ProcessorCount
},
file =>
{
try

View File

@@ -213,6 +213,10 @@ public sealed partial class ImportRomFolderViewModel : ViewModelBase
_stopwatch.Restart();
Parallel.ForEach(_rootImporter.Files,
new ParallelOptions
{
MaxDegreeOfParallelism = Environment.ProcessorCount
},
file =>
{
Dispatcher.UIThread.Post(() =>
@@ -284,6 +288,10 @@ public sealed partial class ImportRomFolderViewModel : ViewModelBase
_stopwatch.Restart();
Parallel.ForEach(_rootImporter.Archives,
new ParallelOptions
{
MaxDegreeOfParallelism = Environment.ProcessorCount
},
archive =>
{
Dispatcher.UIThread.Post(() =>
@@ -365,6 +373,10 @@ public sealed partial class ImportRomFolderViewModel : ViewModelBase
_stopwatch.Restart();
Parallel.ForEach(_rootImporter.Archives,
new ParallelOptions
{
MaxDegreeOfParallelism = Environment.ProcessorCount
},
archive =>
{
Dispatcher.UIThread.Post(() =>