We often need to repeat some method calls, until some condition is met.
For example:
- Try to save a file, if it fails, try again, until it succeeds, but no more than 10 times in total.
- Ping a server, 100 times, and pause two seconds between each ping.
- Try to open a file, in a low-priority background thread, and when it succeeds, call some callback method, if it fails opening the file, try again, but call another callback method every time it fails.
And so on...
More...