private async void B_Click(object sender, EventArgs e) { var button = sender as Button; int index = (int)button.Tag; if (_game.IsValidMove(index)) { button.Text = _game.CurrentPlayer == 1 ? "X" : "O"; if (_game.PerformMove(index)) { await DoComputerMove(index); } CheckGameState(); } }