Пример #1
0
        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);
            }
        }
Пример #2
0
        /// <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);
            }
        }
Пример #3
0
        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);
            }
        }