public Promise(Action <Action <PromisedT>, Action <Exception> > resolver) { this.CurState = PromiseState.Pending; this.Id = ++Promise.nextPromiseId; if (Promise.EnablePromiseTracking) { Promise.pendingPromises.Add(this); } try { resolver( // Resolve value => Resolve(value), // Reject ex => Reject(ex) ); } catch (Exception ex) { RSGUtil.LogCaughtException(ex); Reject(ex); } }
/// <summary> /// Invoke a single resolve handler. /// </summary> private void InvokeResolveHandler(Action callback, IRejectable rejectable) { // Argument.NotNull(() => callback); // Argument.NotNull(() => rejectable); try { callback(); } catch (Exception ex) { RSGUtil.LogCaughtException(ex); rejectable.Reject(ex); } }
public Promise(Action <Action, Action <Exception> > resolver) { this.CurState = PromiseState.Pending; if (EnablePromiseTracking) { pendingPromises.Add(this); } try { resolver( // Resolve () => Resolve(), // Reject ex => Reject(ex) ); } catch (Exception ex) { RSGUtil.LogCaughtException(ex); Reject(ex); } }