private void TryConnect(System.Action action)
{
int retries = 3;
while(true)
{
try
{
action();
break; //success!
}
catch
{
if (--retries == 0)
{
//........
break;
}
else Thread.Sleep(1000);
}
}
}