diff --git a/MaddoShared/ImageCreationStuff.cs b/MaddoShared/ImageCreationStuff.cs index 277994f..439f3dc 100644 --- a/MaddoShared/ImageCreationStuff.cs +++ b/MaddoShared/ImageCreationStuff.cs @@ -149,32 +149,12 @@ namespace MaddoShared }, maxDegreeOfParallelism: threads, false, cancellationToken); - //var throttler = new SemaphoreSlim(initialCount: threads); - //foreach (var fileData in dataToProcess) - //{ - // await throttler.WaitAsync(); - // allTasks.Add(Task.Factory.StartNew(() => { - // try - // { - // new ImageCreatorSharp(fileData.File, fileData.Directory).CreaImmagineThread( - // fileData.File.Name); - // } - // finally - // { - // throttler.Release(); - // } - // }, CancellationToken.None, TaskCreationOptions.None, scheduler)); - //} - - //await Task.WhenAll(test); } else { - var asdf = SplitList(dataToProcess.ToList(), dataToProcess.Count()).ToList(); - //var sadf = asdf[0]; - - //var sadf1 = asdf[1]; + var asdf = SplitList(dataToProcess.ToList(), options.ChunksSize).ToList(); + foreach (var sdaf in asdf) { @@ -197,22 +177,9 @@ namespace MaddoShared - //foreach (var chunk in asdf) - //{ - // await Task.WhenAll(chunk); - // GC.Collect(); - // //GC.WaitForPendingFinalizers(); - // //GC.Collect(); - //} - } } - //foreach (var task in test) - //{ - // await task; - //} - } diff --git a/imagecatalog/MainForm.Designer.cs b/imagecatalog/MainForm.Designer.cs index d1235e4..6aa73c4 100644 --- a/imagecatalog/MainForm.Designer.cs +++ b/imagecatalog/MainForm.Designer.cs @@ -37,6 +37,7 @@ namespace ImageCatalog [DebuggerStepThrough()] private void InitializeComponent() { + this.components = new System.ComponentModel.Container(); this.ProgressBar1 = new System.Windows.Forms.ProgressBar(); this.CheckBox22 = new System.Windows.Forms.CheckBox(); this.Label43 = new System.Windows.Forms.Label(); @@ -175,6 +176,7 @@ namespace ImageCatalog this.Label10 = new System.Windows.Forms.Label(); this._Button6 = new System.Windows.Forms.Button(); this._btnCreaCatalogoAsync = new System.Windows.Forms.Button(); + this.timer1 = new System.Windows.Forms.Timer(this.components); this.TabControl1.SuspendLayout(); this.TabPage5.SuspendLayout(); this.GroupBox11.SuspendLayout(); @@ -1602,11 +1604,12 @@ namespace ImageCatalog // // _btnCreaCatalogoAsync // + this._btnCreaCatalogoAsync.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this._btnCreaCatalogoAsync.Location = new System.Drawing.Point(539, 78); this._btnCreaCatalogoAsync.Name = "_btnCreaCatalogoAsync"; this._btnCreaCatalogoAsync.Size = new System.Drawing.Size(192, 38); this._btnCreaCatalogoAsync.TabIndex = 68; - this._btnCreaCatalogoAsync.Text = "Inizia"; + this._btnCreaCatalogoAsync.Text = "CREA"; this._btnCreaCatalogoAsync.UseVisualStyleBackColor = true; this._btnCreaCatalogoAsync.Click += new System.EventHandler(this.Button1_Click); // @@ -2141,6 +2144,7 @@ namespace ImageCatalog internal CheckBox CheckBox2; internal CheckBox chkSovrascriviFile; private Button _btnCreaCatalogoAsync; + private Timer timer1; internal Button btnCreaCatalogoAsync { diff --git a/imagecatalog/MainForm.cs b/imagecatalog/MainForm.cs index a61ad26..ff93826 100644 --- a/imagecatalog/MainForm.cs +++ b/imagecatalog/MainForm.cs @@ -1534,12 +1534,21 @@ namespace ImageCatalog imageCreationOptions.ChunksSize = Conversions.ToInteger(TextBox8.Text); imageCreationOptions.LinearExecution = rdbVecchioMetodo.Checked; + + try { _results = new ConcurrentBag(); + _currentAmount = 0; + _previousAmount = 0; + timer1.Tick += Timer1OnTick; + + timer1.Interval = 1000 * 60; + timer1.Enabled = true; string time = await imgStf.CreaCatalogoParallel(imageCreationOptions, _results, UiUpdateEvent, token); Label43.Text = time; + timer1.Enabled = false; } catch (OperationCanceledException operationCanceledException) { @@ -1548,11 +1557,23 @@ namespace ImageCatalog finally { _mainToken.Dispose(); + + timer1.Tick -= Timer1OnTick; } Label10.Text = "Finito"; unlockUI(); } + private int _currentAmount = 0; + private int _previousAmount = 0; + private void Timer1OnTick(object sender, EventArgs e) + { + _previousAmount = _currentAmount; + _currentAmount = _results.Count; + int diff = _currentAmount - _previousAmount; + SetText(Label43, $"{diff} f/m"); + } + private void UpdateCounter(string text) { Label10.Invoke(new Action(() => Label10.Text = text)); diff --git a/imagecatalog/MainForm.resx b/imagecatalog/MainForm.resx index 1af7de1..1f666f2 100644 --- a/imagecatalog/MainForm.resx +++ b/imagecatalog/MainForm.resx @@ -117,4 +117,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 17, 17 + \ No newline at end of file