Skip to content

Commit 72e0e7b

Browse files
committed
Don't sleep on last failure
1 parent 623c750 commit 72e0e7b

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/ExchangeSharp/API/Exchanges/_Base/ExchangeAPI.cs

+7-3
Original file line numberDiff line numberDiff line change
@@ -393,9 +393,10 @@ public static IExchangeAPI GetExchangeAPI(Type type)
393393
{
394394
api = (Activator.CreateInstance(foundType, true)as ExchangeAPI) !;
395395
Exception? ex = null;
396+
const int retryCount = 3;
396397

397-
// try up to 3 times to init
398-
for (int i = 0; i < 3; i++)
398+
// try up to n times to init
399+
for (int i = 1; i <= retryCount; i++)
399400
{
400401
try
401402
{
@@ -406,7 +407,10 @@ public static IExchangeAPI GetExchangeAPI(Type type)
406407
catch (Exception _ex)
407408
{
408409
ex = _ex;
409-
Thread.Sleep(5000);
410+
if (i != retryCount)
411+
{
412+
Thread.Sleep(5000);
413+
}
410414
}
411415
}
412416

0 commit comments

Comments
 (0)