public void AwaitUnsafeOnCompleted <TAwaiter, TStateMachine>(ref TAwaiter awaiter, ref TStateMachine stateMachine) where TAwaiter : ICriticalNotifyCompletion where TStateMachine : IAsyncStateMachine { var firstAwait = this.promise == null; if (firstAwait) { this.promise = new Promise <T>(); if (awaiter is ISwitchCaseCondition cond) { this.cond = cond; } var w = new StateMachineWrapper <TStateMachine>(); this.continuation = w.MoveNext; w.StateMachine = stateMachine; } awaiter.UnsafeOnCompleted(this.continuation); }
public SwitchCase(ISwitchCaseCondition cond, Awaiter <T> awaiter) => (this.cond, this.awaiter) = (cond, awaiter);