Calcolo foto al minuto

This commit is contained in:
Maddo Scientisto 2021-03-04 11:25:40 +01:00
commit 4cfc537246
4 changed files with 31 additions and 36 deletions

View file

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

View file

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

View file

@ -1534,12 +1534,21 @@ namespace ImageCatalog
imageCreationOptions.ChunksSize = Conversions.ToInteger(TextBox8.Text);
imageCreationOptions.LinearExecution = rdbVecchioMetodo.Checked;
try
{
_results = new ConcurrentBag<string>();
_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));

View file

@ -117,4 +117,7 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>