Esempio n. 1
0
        // UI
        //----------------------------------------------------------------------------------------------------------

        private void btn_start_Click(object sender, EventArgs e)
        {
            if (!WarWorker.IsBusy)
            {
                btn_start.Text = "&Stop";
                btn_start.Focus();

                num_iterations.Enabled  = false;
                num_threads.Enabled     = false;
                cb_dealfirst.Enabled    = false;
                chk_jokers.Enabled      = false;
                chk_fastshuffle.Enabled = false;

                lbl_status.Text = String.Format("Simulating (0/{0})", num_iterations.Value);
                LogMessage(String.Format("Simulating {0} games...", num_iterations.Value));

                // Create array of arugments to pass
                List <object> Arguments = new List <object>();

                Arguments.Add((long)num_iterations.Value);  // Games
                Arguments.Add(cb_dealfirst.SelectedIndex);  // Deal first
                Arguments.Add(chk_fastshuffle.Checked);     // Fast shuffle
                Arguments.Add(chk_jokers.Checked);          // Jokers
                Arguments.Add((int)num_threads.Value);      // Number of threads

                WarWorker.RunWorkerAsync(Arguments);
            }
            else
            {
                btn_start.Text = "&Start";
                WarWorker.CancelAsync();
            }
        }
Esempio n. 2
0
 private void War_FormClosing(object sender, FormClosingEventArgs e)
 {
     // Stop the worker thread when the form is closing
     if (WarWorker.IsBusy)
     {
         WarWorker.CancelAsync();
     }
 }