예제 #1
0
 private void PauseButton_Click(object sender, EventArgs e)
 {
     //Flip between pause and resume
     if (!toggle)
     {
         pauseButton.Text = "Resume";
         Changer.PauseThread();
     }
     else
     {
         pauseButton.Text = "Pause";
         Changer.ResumeThread();
     }
     toggle = !toggle;
 }
예제 #2
0
        private void CancelButton_Click(object sender, EventArgs e)
        {
            bool toggleCopy = toggle;

            if (!toggleCopy)
            {
                Changer.PauseThread();
                toggleCopy = true;
            }
            if (MessageBox.Show("Are you sure you want to cancel?\nOperations in progress will complete and exit", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                //In case thread is paused, resume it so it can stop gracefully
                Changer.ResumeThread();

                //Send cancel request to threads
                bgWorker.CancelAsync();

                DialogResult = DialogResult.OK;
            }
            else if (toggleCopy)
            {
                Changer.ResumeThread();
            }
        }