int noOfAttempts = 3;
void StartServer();
bool IsServerRunning();
I need to re-attempt StartServer()
3 times based on result from IsServerRunnig()
. Something like this:
StartServer();
if (!IsServerRunning())
{
StartServer();
if (!IsServerRunning())
{
StartServer();
if (!IsServerRunning())
{
StartServer();
}
}
}
I don't want to use for loops or the ugly code like above. Is there a better way of doing this? A way in which, I won't have to change my code if noOfAttempts
change in future?
EDIT: I'm expecting something from the "delegate" concept (If possible).