How can i pause/continue backgroundworker?
<p>I have a button click event for continue:</p>

<pre><code> private void button3_Click(object sender, EventArgs e)
        {
            if (backgroundWorker1.IsBusy)
            {
                button2.Enabled = true;
                button3.Enabled = false;
            }
            else
            {
                backgroundWorker1.RunWorkerAsync();
                button2.Enabled = true;
                button3.Enabled = false;
            }

        }
</code></pre>

<p>And a button click event for pausing:</p>

<pre><code>private void button2_Click(object sender, EventArgs e)
        {
            if (backgroundWorker1.WorkerSupportsCancellation == true)
            {
                backgroundWorker1.CancelAsync();
                button3.Enabled = true;
                soundPlay = false;
                stop_alarm = true;
            }

        }
</code></pre>

<p>The problem is with the button3 click event the continue code sometimes the background is busy so i can enable false/true the buttons but the backgroundworker is keep working.
I want to pause the DoWork event and to continue.</p>

<p>This is my DoWork event:</p>

<pre><code>private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;
            while (true)
            {
                if ((worker.CancellationPending == true))
                {
                    e.Cancel = true;
                    break;
                }
                else
                {
                    if (tempCpuValue &gt;= (float?)numericUpDown1.Value || tempGpuValue &gt;= (float?)numericUpDown1.Value)
                    {
                        soundPlay = true;
                        blinking_label();
                    }
                    else
                    {
                        soundPlay = false;
                    }
                    cpuView();
                    gpuView();
                    Thread.Sleep(1000);
                }
            }
        }
</code></pre>
