Why "Continue" button is not enabled

  • Thread starter Thread starter Curious
  • Start date Start date
C

Curious

I have two buttons on a form, "Pause" and "Continue".

When "Pause" button is clicked, it should:

1) Stop the background worker;
and, 2) Enable the "Continue" button.

I have the code below to explicitly enable the "Continue" button.
However, it's still not enabled. Anyone can tell me why? Thanks.

--------------------------------------------------------------------------------------------------------------------
protected void pauseButton_Click(object sender, EventArgs e)
{


if (mBaseWorker.BackgroundWorker != null)
{
mBaseWorker.BackgroundWorker.CancelAsync();
}

this.continueButton.Enabled = true;
this.Refresh();

}
--------------------------------------------------------------------------------------------------------------------
 
Is there any evidence that the backgroundworker is canceled? I would try
catching any exceptions first in this routine. If you can't get past the
first block you would never see the enabled button. Also, refresh should not
be necessary.
 
If I put "this.continueButton.Enabled = true;" before the block about
the background worker, the "Continue" button won't be enabled either,
although in the debugger, this line does get executed.
 
I normally would not pause a background process by cancelling it. Is it
possible the cancel code for the thread disables the continue button? I ask
this because if the thread is "canceled" it should not be able to be
"continued".
 
To give you an update, the "CancelAsync();" method calls an
"UpdateControls" method that sets the "Continue" button to disabled.
I've fixed the code in these other methods and the "Continue" button
is enabled!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top