Using the WorkflowInvoker Class
This sample demonstrates how to use the WorkflowInvoker class to invoke an activity as if it were a method.
Using the WorkflowInvoker class is the simplest way to execute an activity. It is designed for directly running an activity as if it were a method call. It is a lightweight, high-performing, easy to use API for use in scenarios where an activity’s execution does not require the control infrastructure provided by other hosting variations.
The sample uses a custom activity that derives from CodeActivity<Int32> named
Add that adds two InArgument,
Y, and returns a
ResultOutArgument. (CodeActivity<T> derives from Activity<T>, which has an OutArgument<T> named
Dictionary<string, object> is used to pass arguments into an activity being invoked through WorkflowInvoker. The key of the dictionary corresponds to the name of an argument on the invoked activity. The value associated with a particular key is bound to the argument identified by the key.
The sample calls Invoke and passes a dictionary that contains values for
Y. The WorkflowInvoker class binds these values to the
Add activity’s arguments, executes the activity, and returns the result.
To use this sample
Using Visual Studio 2010, open the Invoker.sln solution file.
To build the solution, press CTRL+SHIFT+B.
To run the solution, press F5.
The samples may already be installed on your machine. Check for the following (default) directory before continuing.