It sounds like you really need a loop. I would write this as:
bool successful = false; while (!successful) { try { while(true) { // I hope you have a break in here somewhere... } successful = true; } catch (...) { ... } }
Instead, you can use the do / while ; I prefer direct while loops, but this is a personal preference, and I see how this might be more appropriate.
I would not use goto . This makes the code more complex.
Of course, if you really want an infinite loop, just put a try/catch inside the loop:
while (true) { try { ... } catch (Exception) { ... } }
source share