public static void ThrowUnhandledRejections() { if (_unhandledExceptions.IsEmpty) { return; } var unhandledExceptions = _unhandledExceptions; _unhandledExceptions.ClearAndDontRepool(); Action <UnhandledException> handler = Promise.Config.UncaughtRejectionHandler; if (handler != null) { foreach (UnhandledException unhandled in unhandledExceptions) { handler.Invoke(unhandled); } unhandledExceptions.Clear(); return; } #if CSHARP_7_OR_LATER var ex = new AggregateException(unhandledExceptions); unhandledExceptions.Clear(); throw ex; #else // .Net 3.5 dumb compiler can't convert IEnumerable<UnhandledExceptionInternal> to IEnumerable<Exception> var exceptions = new List <Exception>(); foreach (var ex in unhandledExceptions) { exceptions.Add(ex); } unhandledExceptions.Clear(); throw new AggregateException(exceptions); #endif }
static ProgressDelegateBase() { OnClearPool += () => _pool.ClearAndDontRepool(); }