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

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