Why "Continue" button is not enabled

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Curious

    Why "Continue" button is not enabled

    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_Cli ck(object sender, EventArgs e)
    {


    if (mBaseWorker.Ba ckgroundWorker != null)
    {
    mBaseWorker.Bac kgroundWorker.C ancelAsync();
    }

    this.continueBu tton.Enabled = true;
    this.Refresh();

    }
    --------------------------------------------------------------------------------------------------------------------
  • =?Utf-8?B?RmFtaWx5IFRyZWUgTWlrZQ==?=

    #2
    RE: Why "Continue& quot; button is not enabled

    Is there any evidence that the backgroundworke r 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.

    "Curious" wrote:
    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_Cli ck(object sender, EventArgs e)
    {
    >
    >
    if (mBaseWorker.Ba ckgroundWorker != null)
    {
    mBaseWorker.Bac kgroundWorker.C ancelAsync();
    }
    >
    this.continueBu tton.Enabled = true;
    this.Refresh();
    >
    }
    --------------------------------------------------------------------------------------------------------------------
    >

    Comment

    • Curious

      #3
      Re: Why "Continue& quot; button is not enabled

      If I put "this.continueB utton.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.

      Comment

      • =?Utf-8?B?RmFtaWx5IFRyZWUgTWlrZQ==?=

        #4
        Re: Why "Continue& quot; button is not enabled

        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" .

        "Curious" wrote:
        If I put "this.continueB utton.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.
        >

        Comment

        • Curious

          #5
          Re: Why "Continue& quot; button is not enabled

          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!

          Comment

          Working...