public IPromise Post(Action action, PromisePriority priority)
        {
            lock (_syncRoot)
            {
                if (_last != null)
                {
                    var ret = _factory.Create(action, priority);
                    _last.Immediately.Finally(() =>
                    {
                        ret.Start();
                    });
                    _last = ret;
                }
                else
                {
                    _last = _factory.StartNew(action, priority);
                }

                return(_last);
            }
        }
Esempio n. 2
0
        public Promise(PromiseFactory factory, Action <Action, Action <Exception> > promise, PromisePriority priority)
        {
            _promise = factory.StartNew(() =>
            {
                Exception error = null;
                bool hasError   = false;

                promise(() =>
                {
                    error    = null;
                    hasError = false;
                }, x =>
                {
                    error    = x;
                    hasError = true;
                });

                if (hasError)
                {
                    throw error;
                }
            }, priority);
        }
Esempio n. 3
0
 public Promise(PromiseFactory factory, Action promise, PromisePriority priority)
 {
     _promise = factory.StartNew(promise, priority);
 }