locked
how do I pass arguments into child activity RRS feed

  • Question

  • I have a native activity that needs to schedule a child native activity. I want the parent native activity to pass an argument into the child native activity and recieve a result (out arg) back from the child native activity when it is done. The schedule activity method does not seem to make provision for passing of arguments and neither does the oncomplete callback have extra parameters to deal with this. Why not?

    If I have several child activities running in parallel, and I try to place these arguments into the parent's context, then I need a way to relate each argument to the right child. Again I think it would be much cleaner and simpler to have the ability to pass aguments specifically to a child in its parents schedule method.
    Wednesday, November 4, 2009 12:46 PM

Answers

  • You should use ActivityDelegate, ActivityAction, or ActivityFunc for this.  See the ActivityAction (under Basic\CustomActivities\Code-Bodied) for a sample of how to use ActivityAction.

    The short version is that when you have an activity that you want to provide values to children as well as get values back from children then you define the signature using ActivityDelegate.  ActivityDelegate allows you to specify the number and type of inputs that the child must have as well as the number and type of outputs.  The methods for scheduling ActivityDelegates allow you to specify the inputs and the completion handler provides the outputs.

    As helpers for common patterns, ActivityAction and ActivityFunc subclasses of ActivityDelegate are provided.  These are simply ActivityDelegate's with preset parameter counts ... ActivityAction<string, int> is a delegate with two input parameters of type string and int.  ActivityFunc<int, string> is a delegate with one input int and one output string.
    Wednesday, November 4, 2009 8:31 PM