Exemple #1
0
        static void Main(string[] args)
        {
            // iteration variable for the ForEach
            var item = new DelegateInArgument <object>();

            // list of elements to iterate
            ArrayList list = new ArrayList();

            list.Add("Bill");
            list.Add("Steve");
            list.Add("Ray");

            // iterate through the list and show the elements
            Activity act =
                new ParallelForEach
            {
                Values = new InArgument <IEnumerable>(ctx => list),
                Body   = new ActivityAction <object>
                {
                    Argument = item,
                    Handler  = new InvokeMethod
                    {
                        TargetType        = typeof(Program),
                        MethodName        = "ShowThreadId",
                        RunAsynchronously = true,
                        Parameters        =
                        {
                            new InArgument <string>(c => item.Get(c).ToString())
                        }
                    }
                }
            };

            WorkflowInvoker.Invoke(act);

            Console.WriteLine("");
            Console.WriteLine("Press enter to exit...");
            Console.ReadLine();
        }
Exemple #2
0
        static void Main(string[] args)
        {
            // iteration variable for the ForEach
            var item = new DelegateInArgument<object>();

            // list of elements to iterate
            ArrayList list = new ArrayList();
            list.Add("Bill");
            list.Add("Steve");
            list.Add("Ray");

            // iterate through the list and show the elements
            Activity act =
                    new ParallelForEach
                    {
                        Values = new InArgument<IEnumerable>(ctx => list),
                        Body = new ActivityAction<object>
                        {
                            Argument = item,
                            Handler = new InvokeMethod
                            {
                                TargetType = typeof(Program),
                                MethodName = "ShowThreadId",
                                RunAsynchronously = true,
                                Parameters =
                                {
                                    new InArgument<string>(c => item.Get(c).ToString())
                                }
                            }
                        }
                    };
            WorkflowInvoker.Invoke(act);

            Console.WriteLine("");
            Console.WriteLine("Press enter to exit...");
            Console.ReadLine();
        }