Пример #1
0
 public PromiseContinuation(Action <object> action, object state, FutureScheduler scheduler, ExecutionContext executionContext)
 {
     _action           = action;
     _state            = state;
     _executionContext = executionContext;
     Scheduler         = FutureScheduler.IsInline(scheduler) ? null : scheduler;
 }
Пример #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);
        }
Пример #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);
        }
Пример #4
0
 public void UnsafeAddContinuation(Action <object> continuation, object state, FutureScheduler scheduler = null)
 {
     AddContinuation(new PromiseContinuation(continuation, state, scheduler, null));
 }
Пример #5
0
 public void UnsafeAddContinuation(Action continuation, FutureScheduler scheduler = null)
 {
     AddContinuation(new PromiseContinuation(continuation, scheduler, null));
 }
Пример #6
0
 public void AddContinuation(Action <object> continuation, object state, FutureScheduler scheduler = null)
 {
     AddContinuation(new PromiseContinuation(continuation, state, scheduler, ExecutionContextEx.Capture()));
 }
Пример #7
0
 public static void SetContextualScheduler(FutureScheduler scheduler)
 {
     t_contextualScheduler = scheduler;
 }
Пример #8
0
 internal static bool IsInline(FutureScheduler scheduler)
 {
     return(scheduler == null || ReferenceEquals(scheduler, Inline));
 }
Пример #9
0
 public FutureSchedulerAwaiter(FutureScheduler scheduler)
 {
     _scheduler = scheduler;
 }
Пример #10
0
 public PromiseContinuation(Action action, FutureScheduler scheduler, ExecutionContext executionContext)
     : this(state => ((Action)state).Invoke(), action, scheduler, executionContext)
 {
 }
Пример #11
0
 /// <summary>
 /// Continue the execution on the specified scheduler after an await
 /// </summary>
 /// <param name="scheduler">The scheduler</param>
 public ScheduledFutureAwaitable ContinueOn(FutureScheduler scheduler)
 {
     return(new ScheduledFutureAwaitable(this, scheduler));
 }