Skip to content

Commit 052209c

Browse files
committed
MaxDegreeOfParallelism
1 parent 8d9c9fc commit 052209c

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

GP Auto Resize/Settings.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,12 @@ public class Settings : SettingsBase<Settings>
6060
[Editor(typeof(DirectoryNameEditor), typeof(UITypeEditor))]
6161
public string BackupLocation { get; set; }
6262

63-
[Category("Settings"), DefaultValue(99), Description("Image quality")]
63+
[Category("Settings"), DefaultValue(95), Description("Image quality")]
6464
public int PhotoQuality { get; set; }
6565

66+
[Category("Settings"), DefaultValue(4), Description("Maximum number of concurrent operations")]
67+
public int MaxDegreeOfParallelism { get; set; }
68+
6669
public Settings()
6770
{
6871
ImageExtensions = new List<string>();

GP Auto Resize/Worker.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ private void ResizePhotosInFolder(string folderPath)
103103

104104
OnProgressChanged(current, max);
105105

106-
Parallel.ForEach(files, filePath =>
106+
Parallel.ForEach(files, new ParallelOptions { MaxDegreeOfParallelism = settings.MaxDegreeOfParallelism }, filePath =>
107107
{
108108
try
109109
{
@@ -129,6 +129,7 @@ private void ResizePhotosInFolder(string folderPath)
129129
}
130130
catch (Exception ex)
131131
{
132+
MessageBox.Show(ex.Message);
132133
Console.WriteLine(ex.Message);
133134
}
134135
finally

0 commit comments

Comments
 (0)