Exemplo n.º 1
0
        public Promise(Action <Action <PromisedT>, Action <Exception> > resolver)
        {
            this.CurState = PromiseState.Pending;
            this.Id       = Promise.NextId();

            if (Promise.EnablePromiseTracking)
            {
                Promise.pendingPromises.Add(this);
            }

            try
            {
                resolver(
                    // Resolve
                    value => Resolve(value),

                    // Reject
                    ex => Reject(ex)
                    );
            }
            catch (Exception ex)
            {
                Reject(ex);
            }
        }
Exemplo n.º 2
0
        public Promise()
        {
            this.CurState = PromiseState.Pending;
            this.id       = Promise.NextId();

            if (Promise.EnablePromiseTracking)
            {
                Promise.PendingPromises.Add(this);
            }
        }
Exemplo n.º 3
0
        public Promise(bool isSync = false)
        {
            this.IsSync   = isSync;
            this.CurState = PromiseState.Pending;
            this.id       = Promise.NextId();

            if (Promise.EnablePromiseTracking)
            {
                Promise.PendingPromises.Add(this);
            }
        }
Exemplo n.º 4
0
        public Promise(Action <Action <PromisedT>, Action <Exception> > resolver)
        {
            CurState = PromiseState.Pending;
            Id       = Promise.NextId();

            if (Promise.EnablePromiseTracking)
            {
                Promise.PendingPromises.Add(this);
            }

            try {
                resolver(Resolve, Reject);
            }
            catch (Exception ex) {
                Reject(ex);
            }
        }
Exemplo n.º 5
0
        public Promise(Action <Action <PromisedT>, Action <Exception> > resolver, bool isSync = false)
        {
            this.IsSync   = isSync;
            this.CurState = PromiseState.Pending;
            this.id       = Promise.NextId();

            if (Promise.EnablePromiseTracking)
            {
                Promise.PendingPromises.Add(this);
            }

            try {
                resolver(this.Resolve, this.Reject);
            }
            catch (Exception ex) {
                this.Reject(ex);
            }
        }
Exemplo n.º 6
0
 private Promise(PromiseState initialState)
 {
     CurState = initialState;
     id       = Promise.NextId();
 }