Fixes/cleans up wait/retry logic

[#78, #79]
This commit is contained in:
Chris Cheetham 2019-11-18 11:39:11 -05:00
Родитель 9f0a850d6a
Коммит 7b61861827
1 изменённых файлов: 7 добавлений и 4 удалений

Просмотреть файл

@ -106,20 +106,23 @@ namespace Steeltoe.Tooling.Executors
while (true) while (true)
{ {
++count; ++count;
if (Settings.MaxChecks >= 0 && ++count > Settings.MaxChecks) if (Settings.MaxChecks > 0)
{ {
throw new ToolingException($"max checks exceeded ({Settings.MaxChecks})"); if (count > Settings.MaxChecks)
{
throw new ToolingException($"max checks exceeded ({Settings.MaxChecks})");
}
} }
var startTicks = DateTime.Now.Ticks;
if (statusCheck(appOrService) == status) if (statusCheck(appOrService) == status)
{ {
break; break;
} }
const int ticksPerMillis = 10000; const int ticksPerMillis = 10000;
var elapsedMillis = (DateTime.Now.Ticks - startTicks) / ticksPerMillis;
const int oneSecondMillis = 1000; const int oneSecondMillis = 1000;
var startTicks = DateTime.Now.Ticks;
var elapsedMillis = (DateTime.Now.Ticks - startTicks) / ticksPerMillis;
var waitMillis = oneSecondMillis - elapsedMillis; var waitMillis = oneSecondMillis - elapsedMillis;
if (waitMillis > 0L) if (waitMillis > 0L)
{ {