public void StopSimulation() { if (!IsSimulating) { return; } lock (simulationControlLock) { if (!IsSimulating) { return; } cancellationTokenSource?.Cancel(); SimulationTask?.Wait(); IsSimulating = false; } }
public void StopSimulation() { if (!IsSimulating) { return; } lock (simulationControlLock) { if (!IsSimulating) { return; } cancellationTokenSource?.Cancel(); try { SimulationTask?.Wait(); } catch (AggregateException e) { } IsSimulating = false; } }