Exemplo n.º 1
0
        public void GameStart(bool breakloop)
        {
            noOfCycles = int.Parse(textBoxInput.Text);

            if (!checkBoxMaxSpeed.Checked)
            {
                timerRun.Start();
            }
            else
            {
                var t = Task.Run(() =>
                {
                    var fw = new FormWait();

                    var tw = Task.Run(() =>
                    {
                        this.Invoke((MethodInvoker) delegate
                        {
                            fw.ShowDialog(this);
                        });
                    });

                    CycleValue = 0;
                    while (CycleValue < noOfCycles && buttonStartStop.Text == "Stop")
                    {
                        this.Invoke((MethodInvoker) delegate
                        {
                            if (fw.getState() == false && CycleValue < noOfCycles)
                            {
                                buttonStartStop.Text    = "Continue";
                                buttonRandomise.Enabled = true;
                                buttonReset.Enabled     = true;
                            }

                            gm.NextState();
                            CycleValue++;
                            if (CycleValue == noOfCycles)
                            {
                                buttonStartStop.Text    = "Start";
                                buttonRandomise.Enabled = true;
                                buttonReset.Enabled     = true;
                            }
                        });
                    }
                    this.Invoke((MethodInvoker) delegate
                    {
                        fw.Close();
                    });
                });
            }
        }