locked
the argument in child activity always equals the last item's value of the loop. RRS feed

  • Question

  • Hi,

    i used a C# foreach loop to build my workflow, all the children activities have a inargumente "action", and it is initted by the item of usbsArgument.ActionList. Finally, the child activity be inserted into a sequence activity.

    foreach (PipelineAction actionItem in usbsArgument.ActionList)
                {
                    switch (actionItem.ActionType)
                    {
                        case PipelineActionType.Normal:
                            {
                                sequence.Activities.Add
                                    (
                                    new NormalTaskActivity
                                    {
                                        DisplayName = actionItem.ModuleName,
                                        action=new InArgument<PipelineAction>(env=>actionItem),
                                        dataManager = dataManager,
                                        executionParam = executionParam,
                                        taskParam = taskParam
                                    }
                                    );
                                break;
                            }
                        case PipelineActionType.LongWait:
                            {
                                sequence.Activities.Add
                                    (
                                    new LongWaitActivity
                                    {
                                        DisplayName = actionItem.ModuleName,
                                        action = new InArgument<PipelineAction>(env => actionItem),
                                        dataManager = dataManager,
                                        executionParam = executionParam,
                                        taskParam = taskParam
                                    }
                                    );
                                break;
                            }
                        case PipelineActionType.BuiltIn:
                            {
                                sequence.Activities.Add
                                        (
                                        new BuildInActivity 
                                        {
                                            DisplayName = actionItem.ModuleName,
                                            action = new InArgument<PipelineAction>(env => actionItem),
                                            dataManager = dataManager,
                                            executionParam = executionParam,
                                            taskParam = taskParam
                                        }
                                        );
                                break;
                            }
                        default:
                            break;
                    }
                }

    my question is: when i execute the workflow. in the first child activity, i get the InArgument "action", but it always equals the last item's value of the loop.

    public InArgument<PipelineAction> PipelineAction { get; set; }

    protected override void Execute(CodeActivityContext context) { PipelineAction pipelineAction = PipelineAction.Get(context);

    }

    it is strange and how can i solve this problem?

    thanks

    Sunday, March 31, 2013 1:19 PM