private async Task PollForChanges(
     string key,
     Action <ConsulWatchExceptionContext> onException,
     CancellationToken cancellationToken)
 {
     while (!cancellationToken.IsCancellationRequested)
     {
         try
         {
             if (await HasValueChanged(key, cancellationToken).ConfigureAwait(false))
             {
                 ConfigurationReloadToken previousToken = Interlocked.Exchange(
                     ref _reloadToken,
                     new ConfigurationReloadToken());
                 previousToken.OnReload();
                 return;
             }
         }
         catch (Exception exception)
         {
             var exceptionContext = new ConsulWatchExceptionContext(cancellationToken, exception);
             onException?.Invoke(exceptionContext);
         }
     }
 }
예제 #2
0
 private async Task PollForChanges(Action <ConsulWatchExceptionContext> onException)
 {
     while (!_source.CancellationToken.IsCancellationRequested)
     {
         try
         {
             if (await HasValueChanged())
             {
                 var previousToken = Interlocked.Exchange(ref _reloadToken, new ConfigurationReloadToken());
                 previousToken.OnReload();
                 return;
             }
         }
         catch (Exception exception)
         {
             var exceptionContext = new ConsulWatchExceptionContext(_source, exception);
             onException?.Invoke(exceptionContext);
         }
     }
 }