Async stop
This commit is contained in:
parent
1cd71c54fc
commit
80fcaa6fd0
4 changed files with 81 additions and 71 deletions
|
|
@ -81,7 +81,7 @@ public partial class MainForm
|
|||
{
|
||||
if (InvokeRequired)
|
||||
{
|
||||
SetTextCallback d = new SetTextCallback(SetText);
|
||||
var d = new SetTextCallback(SetText);
|
||||
this.Invoke(d, new object[] { target, text });
|
||||
}
|
||||
else
|
||||
|
|
@ -113,9 +113,7 @@ public partial class MainForm
|
|||
SetText(Label10, args.Item1);
|
||||
SetText(lblFotoTotaliNum, args.Item2.ToString());
|
||||
}
|
||||
|
||||
/* TODO ERROR: Skipped DefineDirectiveTrivia */
|
||||
private bool StopAttivo;
|
||||
|
||||
private bool WaterSelectColor = false;
|
||||
|
||||
// Private ContaFotoCuori As Integer
|
||||
|
|
@ -758,22 +756,20 @@ public partial class MainForm
|
|||
return NewSize;
|
||||
}
|
||||
|
||||
private void Button7_Click(object sender, EventArgs e)
|
||||
{
|
||||
StopAttivo = true;
|
||||
//MyPool.StopThreadPool();
|
||||
try
|
||||
{
|
||||
_mainToken?.Cancel();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
_logger.LogError(exception.Message);
|
||||
_logger.LogInformation("Ignora questo errore");
|
||||
}
|
||||
|
||||
unlockUI();
|
||||
}
|
||||
// private void Button7_Click(object sender, EventArgs e)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// Model.MainToken?.Cancel();
|
||||
// }
|
||||
// catch (Exception exception)
|
||||
// {
|
||||
// _logger.LogError(exception.Message);
|
||||
// _logger.LogInformation("Ignora questo errore");
|
||||
// }
|
||||
//
|
||||
// unlockUI();
|
||||
// }
|
||||
|
||||
private void Button4_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
|
@ -894,7 +890,7 @@ public partial class MainForm
|
|||
{
|
||||
}
|
||||
|
||||
private CancellationTokenSource? _mainToken;
|
||||
//private CancellationTokenSource? _mainToken;
|
||||
|
||||
private async void Button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
|
@ -902,16 +898,16 @@ public partial class MainForm
|
|||
lockUI();
|
||||
// Dim timeStart As Date
|
||||
// Dim timeStop As Date
|
||||
_mainToken?.Dispose();
|
||||
_mainToken = new CancellationTokenSource();
|
||||
var token = _mainToken.Token;
|
||||
Model.MainToken?.Dispose();
|
||||
Model.MainToken = new CancellationTokenSource();
|
||||
var token = Model.MainToken.Token;
|
||||
|
||||
// timeStart = TimeOfDay
|
||||
FixPaths();
|
||||
Label10.Text = "Elaborazione in corso...";
|
||||
lblFotoTotaliNum.Text = "0";
|
||||
Label18.Text = "0";
|
||||
Model.SpeedCounter = "-s";
|
||||
Model.SpeedCounter = "-f/m";
|
||||
SetPicSettings(Model.SourcePath, Model.DestinationPath);
|
||||
ProgressBar1.Minimum = 0;
|
||||
ProgressBar1.Step = 1;
|
||||
|
|
@ -955,8 +951,8 @@ public partial class MainForm
|
|||
}
|
||||
finally
|
||||
{
|
||||
_mainToken?.Dispose();
|
||||
_mainToken = null;
|
||||
Model.MainToken?.Dispose();
|
||||
Model.MainToken = null;
|
||||
|
||||
timer1.Tick -= Timer1OnTick;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue