Exemplo n.º 1
0
        private Task RegisterActionAsyncCore(LooperAction action)
        {
            lock (_lockQueue)
            {
                if (_isRunning)
                {
                    _registerQueue.Enqueue(action);
                    return(action.Future.Task);
                }
            }

            lock (_lockActions)
            {
                if (_actions.Length == _tail)
                {
                    Array.Resize(ref _actions, checked (_tail * _growFactor));
                }
                _actions[_tail++] = action;
            }

            return(action.Future.Task);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Registers a loop-frame action with state object to the looper and returns <see cref="Task"/> to wait for completion.
        /// </summary>
        /// <param name="loopAction"></param>
        /// <param name="state"></param>
        /// <returns></returns>
        public Task RegisterActionAsync <TState>(LogicLooperActionWithStateDelegate <TState> loopAction, TState state)
        {
            var action = new LooperAction(DelegateHelper.GetWrapper <TState>(), loopAction, state);

            return(RegisterActionAsyncCore(action));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Registers a loop-frame action to the looper and returns <see cref="Task"/> to wait for completion.
        /// </summary>
        /// <param name="loopAction"></param>
        /// <returns></returns>
        public Task RegisterActionAsync(LogicLooperActionDelegate loopAction)
        {
            var action = new LooperAction(DelegateHelper.GetWrapper(), loopAction, null);

            return(RegisterActionAsyncCore(action));
        }