public static PromiseMethodBuilder Create() { Internal.ValidateThreadAccess(1); return(new PromiseMethodBuilder() { _promise = AsyncPromise.GetOrCreate() }); }
private Action GetContinuation <TStateMachine>(ref TStateMachine stateMachine) where TStateMachine : IAsyncStateMachine { if (Task is null) { var promise = AsyncPromise <TStateMachine> .GetOrCreate(); // ORDER VERY IMPORTANT, Task must be set before copying stateMachine. Task = promise; promise.stateMachine = stateMachine; return(promise.continuation); } return(((AsyncPromise)Task).continuation); }