internal virtual void Fulfill(object value) { if (this.promiseState != PromiseState.Pending) { throw new InvalidOperationException("Cannot fulfill a not pending promise"); } ActionObjectDelegate action = (SynchronizationContext != null) ? new ActionObjectDelegate(this.InvokeCall) : new ActionObjectDelegate(this.Call); bool rejected = false; foreach (Action <object> onFulfilledCallback in this.onFulfilledCallbacks) { try { action(onFulfilledCallback, value); } catch (Exception exc) { this.Reject(exc); rejected = true; break; } } if (!rejected) { this.value = value; this.promiseState = PromiseState.Fulfilled; if (this.followingPromise != null) { this.followingPromise.Fulfill(value); } } }
internal virtual void Notify(object value) { ActionObjectDelegate action = (SynchronizationContext != null) ? new ActionObjectDelegate(this.InvokeCall) : new ActionObjectDelegate(this.Call); foreach (Action <object> onNotifyCallback in this.onNotifyCallbacks) { try { action(onNotifyCallback, value); } catch { } } if (this.followingPromise != null) { this.followingPromise.Notify(value); } }