Пример #1
0
        public Awaiter(IScope scope, Action onBreakInner)
        {
            _scope = scope;
            if (_scope.Disposed)
            {
                _unsub = Empty.Action();
                return;
            }

            _break = onBreakInner;
            _scope.Subscribe(OnDispose);
            _unsub = Unsubscribe;

            void Unsubscribe()
            {
                if (!_scope.Disposing)
                {
                    _scope.Unsubscribe(OnDispose);
                }
            }

            void OnDispose()
            {
                if (_continuation != null)
                {
                    InvokeAndFree(ref _continuation);
                }
            }
        }
Пример #2
0
        static void InvokeAndFree(ref Action action)
        {
            var tmp = action;

            action = Empty.Action();
            tmp.Invoke();
        }
Пример #3
0
 public static Awaiter GetAwaiter(this IScope outer)
 {
     return(new Awaiter(outer, Empty.Action()));
 }