Amazon.KinesisTap.Core/Sources/DependentEventSource.cs
/// <summary>
/// Waits until the dependency is available or the polling is cancelled (during source stop),
/// then calls the AfterDependencyRunning method.  Periodically logs during the dependency unavailable outage. 
/// </summary>
Waits until the dependency is available or the polling is cancelled (during source stop),
then calls the AfterDependencyRunning method.  Periodically logs during the dependency unavailable outage.
Waits until the dependency is available or the polling is cancelled ( during source stop ) then calls the AfterDependencyRunning method . Periodically logs during the dependency unavailable outage .
public virtual void Reset()
        {
            int oldValue = Interlocked.CompareExchange(ref this._resetInProgress, 1, 0);
            if (oldValue != 0)
            {
                return;
            }
            if (_cancellationTokenSource != null)
            {
                _cancellationTokenSource.Cancel();
                _cancellationTokenSource = null;
            }
            if (_dependency.IsDependencyAvailable())
            {
                try
                {
                    AfterDependencyAvailable();
                }
                catch (Exception e)
                {
                    _logger?.LogError($"Error invoking AfterDependencyRunning when dependent {_dependency.Name} for source {Id} transitioned to available: {e.ToMinimized()}");
                }
                finally
                {
                    _resetInProgress = 0;
                }
                return;
            }
            _cancellationTokenSource = new CancellationTokenSource();
            CancellationToken token = _cancellationTokenSource.Token;
            Task.Run(() =>
            {
                PollForDependency(token);
            }, 
            token);
        }
public virtual void Reset ( ) { int oldValue = Interlocked . CompareExchange ( ref this . _resetInProgress , 1 , 0 ) ; if ( oldValue != 0 ) { return ; } if ( _cancellationTokenSource != null ) { _cancellationTokenSource . Cancel ( ) ; _cancellationTokenSource = null ; } if ( _dependency . IsDependencyAvailable ( ) ) { try { AfterDependencyAvailable ( ) ; } catch ( Exception e ) { _logger ? . LogError ( $" Error invoking AfterDependencyRunning when dependent  { _dependency . Name }  for source  { Id }  transitioned to available:  { e . ToMinimized ( ) } " ) ; } finally { _resetInProgress = 0 ; } return ; } _cancellationTokenSource = new CancellationTokenSource ( ) ; CancellationToken token = _cancellationTokenSource . Token ; Task . Run ( ( ) => { PollForDependency ( token ) ; } , token ) ; }
Waits until the dependency is available or the polling is cancelled (during source stop),
then calls the AfterDependencyRunning method.
Waits until the dependency is available or the polling is cancelled ( during source stop ) then calls the AfterDependencyRunning method .
// Atomically test and set _resetInProgress to 1 if it is not already 1.  If oldValue != 0 then // some other thread beat us to the reset, so we yield to them.