public async Task RunAsync <TGrid>(int delayMillis, TGrid grid, Dictionary <Coordinate, bool> buffer, int?iterations = null) where TGrid : IConwayGrid { var result = new StepResult(); var executedIterations = 0; while (grid.HasLiveCells()) { Step(result, grid, buffer); grid.SetDictionary(result.State); result.Clear(); if (delayMillis > 0) { await Task.Delay(delayMillis).ConfigureAwait(false); } executedIterations++; if (iterations != null && executedIterations >= iterations) { break; } } }
public void Run <TGrid>(TGrid grid, Dictionary <Coordinate, bool> buffer, int?iterations = null) where TGrid : IConwayGrid { var result = new StepResult(); var executedIterations = 0; while (grid.HasLiveCells()) { Step(result, grid, buffer); grid.SetDictionary(result.State); result.Clear(); executedIterations++; if (iterations != null && executedIterations >= iterations) { break; } } }