How to pause and resume a BackgroundWorker?
<p>This is how i did it in my code:
In the backgroundworker dowork event i did:</p>

<pre><code>private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            _busy.WaitOne();
                this.Invoke(new MethodInvoker(delegate { label2.Text = "Website To Crawl: "; }));
                this.Invoke(new MethodInvoker(delegate { label4.Text = mainUrl; }));
                webCrawler(mainUrl, levelsToCrawl, e);


        }
</code></pre>

<p>Then in the pause button click event i did:</p>

<pre><code>private void button4_Click(object sender, EventArgs e)
        {
            _busy.Reset();
        }
</code></pre>

<p>In the resume button click event i did:</p>

<pre><code>private void button5_Click(object sender, EventArgs e)
        {
            _busy.Set();
        }
</code></pre>

<p>But its not working when i click to start the process:</p>

<pre><code>private void button1_Click(object sender, EventArgs e)
        {
            backgroundWorker1.RunWorkerAsync();
            button1.Enabled = false;
            this.Text = "Processing...";
            label6.Text = "Processing...";
            label6.Visible = true;
            button2.Enabled = false;
            checkBox1.Enabled = false;
            checkBox2.Enabled = false;
            numericUpDown1.Enabled = false;
            button3.Enabled = true;
        }
</code></pre>

<p>Nothing happen only when i click the resume button the process start then when i click the pause button nothing happen.</p>

<p>I want that when i clcik the start process button it will start the backgroundworker regular then when clicking the pause button it will pause and the resume button it will resume.</p>

<p>What did i do wrong ? Can someone fix my code ?</p>
