public PromiseContinuation(Action <object> action, object state, FutureScheduler scheduler, ExecutionContext executionContext) { _action = action; _state = state; _executionContext = executionContext; Scheduler = FutureScheduler.IsInline(scheduler) ? null : scheduler; }
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); }
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); }
public void UnsafeAddContinuation(Action <object> continuation, object state, FutureScheduler scheduler = null) { AddContinuation(new PromiseContinuation(continuation, state, scheduler, null)); }
public void UnsafeAddContinuation(Action continuation, FutureScheduler scheduler = null) { AddContinuation(new PromiseContinuation(continuation, scheduler, null)); }
public void AddContinuation(Action <object> continuation, object state, FutureScheduler scheduler = null) { AddContinuation(new PromiseContinuation(continuation, state, scheduler, ExecutionContextEx.Capture())); }
public static void SetContextualScheduler(FutureScheduler scheduler) { t_contextualScheduler = scheduler; }
internal static bool IsInline(FutureScheduler scheduler) { return(scheduler == null || ReferenceEquals(scheduler, Inline)); }
public FutureSchedulerAwaiter(FutureScheduler scheduler) { _scheduler = scheduler; }
public PromiseContinuation(Action action, FutureScheduler scheduler, ExecutionContext executionContext) : this(state => ((Action)state).Invoke(), action, scheduler, executionContext) { }
/// <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)); }