public async Task <bool> ExistsAsync(MyCatRelationalConnection conn, bool retryOnNotExists, CancellationToken cancellationToken) { var retryCount = 0; while (true) { try { await conn.OpenAsync(cancellationToken); conn.Close(); return(true); } catch (MyCatException e) { if (!retryOnNotExists && IsDoesNotExist(e)) { return(false); } if (!RetryOnExistsFailure(e, ref retryCount)) { throw; } } } }
public bool Exists(MyCatRelationalConnection conn, bool retryOnNotExists = false) { var retryCount = 0; var giveUp = DateTime.UtcNow + TimeSpan.FromMinutes(1); while (true) { try { conn.Open(); conn.Close(); return(true); } catch (MyCatException e) { if (!retryOnNotExists && IsDoesNotExist(e)) { return(false); } if (DateTime.UtcNow > giveUp || !RetryOnExistsFailure(e, ref retryCount)) { throw; } } } }