internal static Action CaptureExecutionContext(this Action action) { var context = ExecutionContextEx.Capture(); if (context == null) { return(action); } return(() => ExecutionContextEx.Run(context, state => ((Action)state).Invoke(), action)); }
public void Invoke() { if (Scheduler == null) { if (_executionContext == null) { _action(_state); } else { ExecutionContextEx.Run(_executionContext, s_executionContextCallback, this); } } else { Scheduler.UnsafeSchedule(s_schedulerCallback, this); } }
public void AddContinuation(Action <object> continuation, object state, FutureScheduler scheduler = null) { AddContinuation(new PromiseContinuation(continuation, state, scheduler, ExecutionContextEx.Capture())); }