public void Invoke(Exception error)
        {
            try
            {
                if (ExceptionEqualityComparer.Equals(error, Interlocked.Exchange(ref lastError, error)))
                {
                    return;
                }

                callback?.Invoke(error);
            }
            catch
            {
                // ignored
            }
        }
Ejemplo n.º 2
0
        public void Invoke(Exception error)
        {
            try
            {
                var newLastError = Tuple.Create(error, DateTimeOffset.UtcNow);
                var oldLastError = Interlocked.Exchange(ref lastError, newLastError);
                if (oldLastError != null && ExceptionEqualityComparer.Equals(error, oldLastError.Item1) && newLastError.Item2 - oldLastError.Item2 < cooldown)
                {
                    return;
                }

                callback?.Invoke(error);
            }
            catch
            {
                // ignored
            }
        }