コード例 #1
0
        private void WorkerThread_DoWork(object sender, DoWorkEventArgs e)
        {
            while (!pausado)
            {
                Thread.Sleep(1000);

                CondPartida est = verVez();
                if (est == CondPartida.acabou)
                {
                    fimDeJogo();
                }
                else if (est == CondPartida.minhaVez)
                {
                    jogarAutomatico();
                    listarPontos();
                }

                if (workerThread.CancellationPending)
                {
                    // this is important as it set the cancelled property of RunWorkerCompletedEventArgs to true
                    e.Cancel = true;
                    break;
                }
            }
        }
コード例 #2
0
        /////////////////////////////////////////////////////////////
        public void Jogar(Compra c)
        {
            string txt = Jogo.Jogar(jogador.id, jogador.senha, c.tipo, c.fabrica, c.azulejo, c.modelo);

            Console.WriteLine("joguei");
            Invoke((MethodInvoker) delegate
            {
                lblErro.Text = txt;
            });
            CondPartida est = verVez();

            if (est == CondPartida.acabou)
            {
                fimDeJogo();
            }
            else if (est == CondPartida.minhaVez)
            {
                atualizarAzulejos();
            }
        }//Manda um pedido de compra