现场优化6
This commit is contained in:
@@ -487,9 +487,22 @@ namespace ADP.ViewModels
|
||||
targetRunner.stepCTS.Cancel();
|
||||
targetRunner.errorStepCTS.Cancel();
|
||||
|
||||
await Task.Delay(200);
|
||||
// 💡 等待旧任务真正结束,而不是只等 200ms
|
||||
if (currentTask != null)
|
||||
{
|
||||
try { await currentTask; } catch { /* 取消导致的异常忽略 */ }
|
||||
}
|
||||
if (errorTask != null)
|
||||
{
|
||||
try { await errorTask; } catch { /* 取消导致的异常忽略 */ }
|
||||
}
|
||||
|
||||
// 💡 彻底复位:替换 CTS、清理任务字典、停止计时器、归零状态
|
||||
targetRunner.stepCTS = new CancellationTokenSource();
|
||||
targetRunner.errorStepCTS = new CancellationTokenSource();
|
||||
_executionTasks.TryRemove(runningScope, out _);
|
||||
_errorExecutionTasks.TryRemove(runningScope, out _);
|
||||
|
||||
// 💡 彻底复位:停止当前工位的计时器,并且完全归零(Reset)
|
||||
targetContext.SW.Reset();
|
||||
targetContext.RunningTime = TimeSpan.Zero;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user