private async Task StartPullingDocs() { PullingTask = PullDocuments().ObserveException(); try { await PullingTask.ConfigureAwait(false); } catch (Exception) { if (cts.Token.IsCancellationRequested) { return; } PullingTask = null; RestartPullingTask().ConfigureAwait(false); } if (IsErrored) { OnCompletedNotification(); try { await CloseSubscription().ConfigureAwait(false); } catch (Exception e) { logger.WarnException("Exception happened during an attempt to close subscription after it becomes faulted", e); } } }
private async Task StartPullingDocs() { PullingTask = PullDocuments().ObserveException(); try { await PullingTask.ConfigureAwait(false); } catch (Exception ex) { if (cts.Token.IsCancellationRequested) { return; } PullingTask = null; SubscriptionException subscriptionEx; var ere = ex as ErrorResponseException; if (ere != null && AsyncDocumentSubscriptions.TryGetSubscriptionException(ere, out subscriptionEx)) { if (subscriptionEx is SubscriptionClosedException) { // someone forced us to drop the connection by calling Subscriptions.Release OnCompletedNotification(); IsClosed = true; return; } } RestartPullingTask().ConfigureAwait(false); } if (IsErrored) { OnCompletedNotification(); try { await CloseSubscription().ConfigureAwait(false); } catch (Exception e) { logger.WarnException("Exception happened during an attempt to close subscription after it becomes faulted", e); } } }