private async Task EnsureSendHealthUpdateAsync(HealthUpdate update) { int repeats = 1; while (!_cancelationTokenSource.IsCancellationRequested) { try { await SendHealthUpdateAsync(update); return; } catch (Exception e) when (!_cancelationTokenSource.IsCancellationRequested) { _logger.Error("Unable to send health update", e); await SafeDelay(TimeSpan.FromSeconds(Math.Min(MaxRepeatDelayInSecs, repeats))); repeats *= 2; } } }
private async Task SendHealthUpdateAsync(HealthUpdate update) { var endpointId = _endpointId ?? (_endpointId = await RegisterEndpointAsync()).Value; try { await _client.SendHealthUpdateAsync(endpointId, _definition.Password, update, _cancelationTokenSource.Token); } catch (EndpointNotFoundException) { _endpointId = null; } }