Esempio n. 1
0
 private void NextStep(object sender, RoutedEventArgs e)
 {
     if (!this.ThreadAlive && conway.HasMatrix())
     {
         conway.Iterate();
         iterations.Text = $"Iteraciones: {conway.Iterations}";
         alive.Text      = $"Celdas vivas: {conway.LiveCells}";
         this.Renderer.AddDirty(conway);
     }
 }
Esempio n. 2
0
        public void Iterate()
        {
            var sw = Stopwatch.StartNew();

            while (window.ThreadAlive)
            {
                canvas.Iterate();
                window.Renderer.AddDirty(canvas);
                Dispatcher.UIThread.InvokeAsync(new Action(
                                                    delegate()
                {
                    window.iterations.Text = $"Iteraciones: {canvas.Iterations}";
                    window.alive.Text      = $"Celdas vivas: {canvas.LiveCells}";
                }
                                                    ));
                if (this.speed != 0)
                {
                    Thread.Sleep(this.speed * 50);
                }
                if (n > 0)
                {
                    n--;
                }
                if (n == 0)
                {
                    break;
                }
            }
            sw.Stop();
            Dispatcher.UIThread.InvokeAsync(new Action(
                                                delegate()
            {
                window.iterBlock.Text = $"Tiempo: {sw.Elapsed}";
            }
                                                ));
            window.ThreadAlive = false;
        }