public async void FetchConnectionToken(IConnectionTokenCallback callback) { var isSuccess = false; do { try { var token = await _connectionTokenProviderService.FetchConnectionToken(); isSuccess = true; callback.OnSuccess(token); } catch (Throwable ex) { if (_retries >= MaxRetries) { callback.OnFailure(new ConnectionTokenException("Failed to fetch connection token", ex)); } } catch (System.Exception ex) { if (_retries >= MaxRetries) { callback.OnFailure(new ConnectionTokenException("Failed to fetch connection token", new Throwable(ex.Message))); } } _retries++; } while (_retries < MaxRetries && isSuccess == false); }
public override async void FetchConnectionToken(SCPConnectionTokenCompletionBlock completion) { var isSuccess = false; do { try { var token = await _connectionTokenProviderService.FetchConnectionToken(); isSuccess = true; completion(token, null); } catch (Exception ex) { if (_retries >= MaxRetries) { completion(null, new NSError(new NSString(ex.Message), 0)); } } _retries++; } while (_retries < MaxRetries && isSuccess == false); }