private void backgroundWorker2_DoWork(object sender, DoWorkEventArgs e) { //AI only TournamentMaster TM = (TournamentMaster)e.Argument; //TM.tmp(); skyNet = TM.Go(10, 5); if (backgroundWorker2.WorkerSupportsCancellation == true) { // Cancel the asynchronous operation. backgroundWorker2.CancelAsync(); } }
private void button1_Click(object sender, EventArgs e) { printMessageGui(""); TournamentMaster TM = new TournamentMaster(5, 10, this); //GameMaster GM = new GameMaster(this); backgroundWorker2 = new BackgroundWorker(); backgroundWorker2.WorkerReportsProgress = true; backgroundWorker2.WorkerSupportsCancellation = true; backgroundWorker2.DoWork += backgroundWorker2_DoWork; if (backgroundWorker2.IsBusy != true) { // Start the asynchronous operation. //backgroundWorker2.RunWorkerAsync(GM); backgroundWorker2.RunWorkerAsync(TM); } }