private Promise <at> registerCallbacks <at>(Func <t, Promise <at> > onComplete, Action <Exception> onFailure) { return(Atomic.Promise <at> ((resolve, reject) => { lock (this.resolveLock) { this.completedListeners.Push(() => onComplete(this.value).WhenDone(resolve, onFailure)); this.failureListeners.Push(onFailure); } })); }
private Promise <at> notifyCallback <at>(Func <t, Promise <at> > onComplete, Action <Exception> onFailure) { return(Atomic.Promise <at> ((resolve, reject) => { if (onComplete != null && this.rejection == null) { onComplete(this.value).WhenDone(resolve, onFailure); } else if (onFailure != null) { onFailure(this.rejection); } else { throw this.rejection; } })); }