现场优化6

This commit is contained in:
2026-08-17 15:52:48 +08:00
parent 2bb8313f99
commit fb6e5b3cb1
61 changed files with 23694 additions and 146356 deletions
+15 -2
View File
@@ -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;