Пример #1
0
        /// <summary>
        /// Provide the an option for the callee to block until all commands are executed
        /// </summary>
        /// <param name="commands"></param>
        /// <returns></returns>
        public static List <WaitHandle> ExecuteAsyncCommandExec(IEnumerable <ICommandExec> commands)
        {
            var waitHandles = new List <WaitHandle>();

            foreach (var command in commands)
            {
                var waitHandle = new AutoResetEvent(false);
                waitHandles.Add(waitHandle);
                var commandExecsHandler = new CommandExecsHandler(command, waitHandle);
                ThreadPool.QueueUserWorkItem(ExecuteCommandList, commandExecsHandler);
            }
            return(waitHandles);
        }
Пример #2
0
        /// <summary>
        /// Provide the an option for the callee to block until all commands are executed
        /// </summary>
        /// <param name="commands"></param>
        /// <returns></returns>
        public static List <WaitHandle> ExecuteAsyncCommandExec(IEnumerable <ICommandExec> commands)
        {
            var waitHandles = new List <WaitHandle>();

            foreach (var command in commands)
            {
                var waitHandle = new AutoResetEvent(false);
                waitHandles.Add(waitHandle);
                var commandExecsHandler = new CommandExecsHandler(command, waitHandle);
#if NETFX_CORE
                ThreadPool.RunAsync(new WorkItemHandler((IAsyncAction) => ExecuteCommandList(commandExecsHandler)));
#else
                ThreadPool.QueueUserWorkItem(ExecuteCommandList, commandExecsHandler);
#endif
            }
            return(waitHandles);
        }