Esempio n. 1
0
        public void ClickJobWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;

            while (true)
            {
                for (int i = 0; i < 2 * seconds; i++)
                {
                    System.Threading.Thread.Sleep(500); //wait half a second and each time, check if cancel has been clicked
                    if (ClickJobWorker.CancellationPending == true)
                    {
                        ClickJobWorker.CancelAsync();
                        e.Cancel = true;
                        return;
                    }
                }
                MouseClicker();
            }
        }
Esempio n. 2
0
        private void StartButton_Click(object sender, EventArgs e)
        {
            string input = textBox1.Text;

            int n = int.MaxValue;

            if (int.TryParse(input, out n) && n > 0)
            {
                seconds             = n;
                label2.Text         = "Running";
                label2.ForeColor    = System.Drawing.Color.Green;
                StartButton.Enabled = false;
                ClickJobWorker.RunWorkerAsync();
            }
            else
            {
                MessageBox.Show("Please enter a valid number bigger than 1.");
            }
        }
Esempio n. 3
0
 private void StopButton_Click(object sender, EventArgs e)
 {
     ClickJobWorker.CancelAsync();
 }