C# question. Debugged complaint: 'Exception was unhandled by user code'
Posted on 2012-04-11
I wonder if someone can tell me what the problem is, as I got the debugger complaint 'Exception was unhandled by user code'. My intention was if the condition fails, the method would throw an exception and would be handled by the caller (or caller of the caller). Had I done anything wrong here?
private static SomeClass Method_1(BackgroundWorker backgroundWorker)
int retryCounter = 0;
response = Utility.DoSomething();
if (response == null)
// Increment 'retryCounter' and re-try for up to 3 times.
if ((retryCounter <= 3) && (!backgroundWorker.CancellationPending))
// Quit! Then return 'false' after re-trying 3 times.
string message3 = "No response to after 3 retry attempts.";
throw new Exception(message3);
return response; // ??? At here, VS2008 complaint 'Exception was unhandled by user code' ???
} while (!backgroundWorker.CancellationPending);