示例#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();
            }
        }
示例#2
0
 private void StopButton_Click(object sender, EventArgs e)
 {
     ClickJobWorker.CancelAsync();
 }