Export (0) Print
Expand All

Using the WorkflowInvoker Class

This sample demonstrates how to use the WorkflowInvoker class to invoke an activity as if it were a method.

Sample Details

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, X and Y, and returns a ResultOutArgument. (CodeActivity<T> derives from Activity<T>, which has an OutArgument<T> named Result.) A 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 X and Y. The WorkflowInvoker class binds these values to the Add activity’s arguments, executes the activity, and returns the result.

To use this sample

  1. Using Visual Studio 2010, open the Invoker.sln solution file.

  2. To build the solution, press CTRL+SHIFT+B.

  3. To run the solution, press F5.

Important Note:
The samples may already be installed on your machine. Check for the following (default) directory before continuing.

<InstallDrive>:\WF_WCF_Samples

If this directory does not exist, go to Windows Communication Foundation (WCF) and Windows Workflow Foundation (WF) Samples for .NET Framework 4 to download all Windows Communication Foundation (WCF) and WF samples. This sample is located in the following directory.

<InstallDrive>:\WF_WCF_Samples\WF\Basic\Execution\WorkflowInvoker




Build Date:

2012-08-02
Show:
© 2014 Microsoft