Example #1
0
        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);
        }
Example #2
0
 public SwitchCase(ISwitchCaseCondition cond, Awaiter <T> awaiter)
 => (this.cond, this.awaiter) = (cond, awaiter);