private void MyThread() { BattleField Battle = BattleField.getBat(); Battle.DelR(); int i = Battle.DoMany(ArmyA, ArmyB); if (i == 1 || i == 2) { if (i == 1) { string s = Battle.WhoWin() + " выиграли!"; Battle.NotifyObserverF(s); MessageBox.Show(s, "Win!", MessageBoxButtons.OK); } else { MessageBox.Show("Ничья.", "GameOver!", MessageBoxButtons.OK); Battle.NotifyObserverF("Ничья."); } Restart.Invoke(new Action(() => Restart.Enabled = true)); UnDo.Invoke(new Action(() => UnDo.Enabled = false)); ReDo.Invoke(new Action(() => ReDo.Enabled = false)); OneStep.Invoke(new Action(() => OneStep.Enabled = false)); Start.Invoke(new Action(() => Start.Enabled = false)); Pause.Invoke(new Action(() => Pause.Enabled = false)); groupBox2.Invoke(new Action(() => groupBox2.Enabled = true)); groupBox1.Invoke(new Action(() => groupBox1.Enabled = true)); } }
private void button3_Click(object sender, EventArgs e) { groupBox2.Invoke(new Action(() => groupBox2.Enabled = false)); groupBox1.Invoke(new Action(() => groupBox1.Enabled = false)); button1.Invoke(new Action(() => button1.Enabled = false)); button1.Invoke(new Action(() => button1.Enabled = false)); Restart.Invoke(new Action(() => Restart.Enabled = false)); UnDo.Invoke(new Action(() => UnDo.Enabled = false)); ReDo.Invoke(new Action(() => ReDo.Enabled = false)); OneStep.Invoke(new Action(() => OneStep.Enabled = false)); Start.Invoke(new Action(() => Start.Enabled = false)); Pause.Invoke(new Action(() => Pause.Enabled = true)); System.Threading.Thread MY = new System.Threading.Thread(MyThread); MY.Start(); }