Exemplo n.º 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);
                }
            }
        }
Exemplo n.º 2
0
        static void InvokeAndFree(ref Action action)
        {
            var tmp = action;

            action = Empty.Action();
            tmp.Invoke();
        }
Exemplo n.º 3
0
 public static Awaiter GetAwaiter(this IScope outer)
 {
     return(new Awaiter(outer, Empty.Action()));
 }