Пример #1
0
        /// <summary>
        /// 添加状态执行方法
        /// </summary>
        /// <param name="func">如果返回值为false,暂停队列</param>
        /// <param name="paramater"></param>
        /// <returns></returns>
        public bool AddWithStatus(Func <T, bool> func, T paramater)
        {
            var executeWorker = new ExecuteWorker <T>(func, paramater);

            return(_blockingCollection.TryAdd(executeWorker));
        }
Пример #2
0
        /// <summary>
        /// 添加执行方法
        /// </summary>
        /// <param name="action"></param>
        /// <param name="paramater"></param>
        /// <returns></returns>
        public bool Add(Action <T> action, T paramater)
        {
            var executeWorker = new ExecuteWorker <T>(action, paramater);

            return(_blockingCollection.TryAdd(executeWorker));
        }