Пример #1
0
 public static List<WaitHandle> ExecAsync(this IEnumerable<Action> actions)
 {
     var waitHandles = new List<WaitHandle>();
     foreach (var action in actions)
     {
         var waitHandle = new AutoResetEvent(false);
         waitHandles.Add(waitHandle);
         var commandExecsHandler = new ActionExecHandler(action, waitHandle);
         ThreadPool.QueueUserWorkItem(x => ((ActionExecHandler)x).Execute(), commandExecsHandler);
     }
     return waitHandles;
 }
Пример #2
0
        public static List<WaitHandle> ExecAsync(this IEnumerable<Action> actions)
        {
            var waitHandles = new List<WaitHandle>();
            foreach (var action in actions)
            {
                var waitHandle = new AutoResetEvent(false);
                waitHandles.Add(waitHandle);
                var commandExecsHandler = new ActionExecHandler(action, waitHandle);
#if NETFX_CORE
                ThreadPool.RunAsync(new WorkItemHandler((IAsyncAction) => commandExecsHandler.Execute()));
#else
                ThreadPool.QueueUserWorkItem(x => ((ActionExecHandler)x).Execute(), commandExecsHandler);
#endif
            }
            return waitHandles;
        }