Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            var grid = new LifeGrid(NumberOfRows, NumberOfColumns);
            var randomGridSeeder = new RandomGridSeeder();
            randomGridSeeder.Seed(grid);

            while (true)
            {
                grid.Tick();

                var cells = grid.GetLivingCells();
                DisplayCells(cells);
                Thread.Sleep(500);
            }
        }
Ejemplo n.º 2
0
        protected void backgroundWorker_DoWork(Object sender, DoWorkEventArgs e)
        {
            var grid = new LifeGrid(NumberOfRows, NumberOfColumns);
            var randomGridSeeder = new RandomGridSeeder();
            randomGridSeeder.Seed(grid);

            while (true)
            {
                if (backgroundWorker.CancellationPending)
                {
                    e.Cancel = true;
                    break;
                }

                grid.Tick();

                var cells = grid.GetLivingCells();
                backgroundWorker.ReportProgress(0, cells);
                Thread.Sleep(TickDelay);
            }
        }