locked
Where to use Arguments? RRS feed

  • Question

  • I am working on WF 4.0 from a week or so but still I am not clear about Arguments. I would like to know in which scenarios Arguments will be best to use? It makes sense to me to use the In and Out Arguments in case of custom activites but in case of standard activites where 'Arguments' use rather then 'Variables' will be effective? or what Argument can do which Varibales cant?
    Thursday, August 20, 2009 6:52 AM

Answers

  • The arguments you create from the designer window are binded with the main workflow and can be used in any of the activities on the workflow.

    The arguments which you are creating from the designer window corresponds to the arguments from host to workflow through a In dictionary object and an Out dictionary object  and are related to the main workflow activity. Observe that the arguments you create from designer window have only In/Out directions same as InArgsdictionary or OutArgsDictionary.
    Also the arguments created from the designer window can be used in any activity on the workflow.

    Try this.
    For ex. First pass Input parameters dictionary null and then create an argument InName from designer and use WriteLine(InName). Invoke the workflow. You will observe it printed nothing.
    Now Add InName with value "test" in the input args dictinary and then create an argument InName from designer and use WriteLine(InName) and then Invoke the workflow. This time it will print "test" on console window.

    I hope it helps you this time
    • Marked as answer by Waleed Ahmed Friday, August 21, 2009 10:07 AM
    Friday, August 21, 2009 7:38 AM

All replies

  • Arguments represent the flow of data into and out of an activity. An activity has a set of arguments and they make up the signature of the activity. Each argument has a specified direction: input, output, or input/output.
    In Workflow 4, arguments can be passed into a workflow using a Dictionary<string, object> of input parameters that map to the input arguments of the workflow.
    When you invoke a workflow using WorkflowInvoker, you call the Invoke method and pass in the workflow definition of the workflow to invoke. It also receives an input dictionary and returns an output dictionary with the results.

    Variable is just like a variable in a function, only here it holds some value for an activity. Big difference is that a Variable is in scope, i.e. visible, to all nested activities as well. So basically it is a way of sharing state between different activities.

    Thursday, August 20, 2009 9:11 AM
  • First of all thanx for the answer.

    I am quite clear about the argument from host to workflow through a dictionary object. What I am still not clear about is the 'Argument' which you can create from desinger window. If u define a new argument you cannot bind it with a specific activty. You can define it as input or output or both but with which acivty it is associated with? Don't you think it will make more sense if you can assoicate with an activtiy? Or is its whole purpose is just to serve host to workflow communication not between activites?
    Friday, August 21, 2009 6:17 AM
  • The arguments you create from the designer window are binded with the main workflow and can be used in any of the activities on the workflow.

    The arguments which you are creating from the designer window corresponds to the arguments from host to workflow through a In dictionary object and an Out dictionary object  and are related to the main workflow activity. Observe that the arguments you create from designer window have only In/Out directions same as InArgsdictionary or OutArgsDictionary.
    Also the arguments created from the designer window can be used in any activity on the workflow.

    Try this.
    For ex. First pass Input parameters dictionary null and then create an argument InName from designer and use WriteLine(InName). Invoke the workflow. You will observe it printed nothing.
    Now Add InName with value "test" in the input args dictinary and then create an argument InName from designer and use WriteLine(InName) and then Invoke the workflow. This time it will print "test" on console window.

    I hope it helps you this time
    • Marked as answer by Waleed Ahmed Friday, August 21, 2009 10:07 AM
    Friday, August 21, 2009 7:38 AM
  • Things are clear now .. 

    Thanx Suchi..
    Friday, August 21, 2009 10:07 AM