Exemplo n.º 1
0
        public Future <TResult> ContinueWith <TResult>(Func <Future, TResult> func, FutureScheduler scheduler = null)
        {
            if (IsCompleted && FutureScheduler.IsInline(scheduler))
            {
                try
                {
                    return(new Future <TResult>(func(this)));
                }
                catch (Exception ex)
                {
                    return(Future.FromException <TResult>(ex));
                }
            }

            var continueWith = new ContinueWithPromise <TResult>(_promise, func, scheduler);

            _promise.AddContinuation(continueWith);

            return(continueWith.Future);
        }
Exemplo n.º 2
0
        public Future ContinueWith(Action <Future> action, FutureScheduler scheduler = null)
        {
            if (IsCompleted && FutureScheduler.IsInline(scheduler))
            {
                try
                {
                    action(this);
                    return(new Future());
                }
                catch (Exception ex)
                {
                    return(Future.FromException(ex));
                }
            }

            var continueWith = new ContinueWithPromise(_promise, action, scheduler);

            _promise.AddContinuation(continueWith);

            return(continueWith.Future);
        }