Can't click button on form during function call in C#

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jakeesgirl
    New Member
    • Oct 2007
    • 17

    Can't click button on form during function call in C#

    I am developing a program in C# Visual Studio and I have a form that is created when a button is clicked on another form. This new form comes up and immediately, a function is called and executed from the load function. After the function is done, the form is closed. I have a 'Cancel' button on the form so the user can have the option cancel the function, but the button can't be clicked while the form is visible. How can I fix this problem?
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    Are you using .ShowDialog() to show that form? If so, it's a blocking call and you willwant to use .Show() instead.

    Another possibility is that it's running in the same thread and it is too busy performing your function to handle your request.

    Comment

    • jakeesgirl
      New Member
      • Oct 2007
      • 17

      #3
      I am using .Show(). Is there any way to avoid the other?

      Comment

      • Plater
        Recognized Expert Expert
        • Apr 2007
        • 7872

        #4
        Run it in a new thread?
        It would be trickier to tell it to "cancel" then (outside of killing the thread)

        Comment

        Working...