public PromiseContinuation(Action <object> action, object state, FutureScheduler scheduler, ExecutionContext executionContext)
 {
     _action           = action;
     _state            = state;
     _executionContext = executionContext;
     Scheduler         = FutureScheduler.IsInline(scheduler) ? null : scheduler;
 }
Example #2
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);
        }
Example #3
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);
        }