0

I have a quandary regarding C++ and .Net/WinForms. I have code written to launch a background worker to check user input against a web server. The code is as follows:

    try {
        loginworker->RunWorkerAsync();                       
    }
    catch(System::InvalidOperationException^) {}

Now, when I run the program and click the login button several times (thus triggering the 'Background worker is already running a task' error), I get an unhandled System::InvalidOperationException at that line of code. Is there something I'm missing here?

I've already written the code in a way that hides the login button until code execution completes on the background worker, but should it not catch the exception?

Collin

Tom Kerr
  • 10,444
  • 2
  • 30
  • 46

1 Answers1

1

Do you have you debugger set to break on all exceptions? What happens if you replace the RunWorkerAsync line with throw gcnew InvalidOperationException();, and click the button once?

David Yaw
  • 27,383
  • 4
  • 60
  • 93