Search

Search:

Namespace:

Search Result
.
        • HandleExternalEventActivity
.

The two activities to interact with the interface are the CallExternalMethodActivity and HandleExternalEventActivity.

.

HandleExternalEventActivity

.

Note that if the Workflow is still executing after the DelayActivity has caused a timeout on the HandleExternalEventActivity the event doesn't raise an error but is never received either.

.

When the StateMachineWorkflow contains an EventDrivenActvity, the EventDrivenActivity has some restrictions. The EventDrivenActivity may contain one, and only one, activity of type IEventActivity, and the HandleExternalEventActivity must be the first child activity. (An HandleExternalEventActivity cannot be in the event handler for a child activity and cannot be a child to the EventDrivenActivity if the HandleExternalEventActivity is not the first child.) As long as the first activity is the HandleExternalEventActivity, the event handler can contain any activities. If an activity other than HandleExternalEventActivity is contained in EventDrivenActivity, that activity cannot have an event handler.

.

Another example is that the EventDrivenActivity can contain a ConditionedActivityGroup, but the ConditionedActivityGroup itself cannot contain any HandleExternalEventActivity classes.

.
Summary
.

The two activities to interact with the interface are the CallExternalMethodActivity and HandleExternalEventActivity.

.

HandleExternalEventActivity

.

The workflow communication activity generator command-line utility, wca.exe, is used to generate strictly bound communications activities from a compiled ExternalDataExchange interface. Whereas the HandleExternalEventActivity and CallExternalMethodActivity activities can both be used directly to handle generic communications in a workflow, the ExternalDataExchange interface strictly bound derived activities provide a better designer experience. These activities improve performance by removing the use of reflection and easing customization for frequently used ExternalDataExchange interfaces.

.

For each operation on the ExternalDataExchange interfaces in the input assembly, wca.exe generates code for the corresponding activity. Events on the interface become derivatives of HandleExternalEventActivity, and methods become derivatives of CallExternalMethodActivity.

.

The wca.exe tool provides the command-line parameters /collapseArgs and /includeSender to determine how the HandleExternalEventActivity subclass properties appear. The /collapseArgs parameter causes a single E property of the EventArgs type to be generated instead of the default, which generates one property on the activity for each public property and field of the EventArgs. The /includeSender parameter includes a Sender property on the activity of type object, which is populated by the sender parameter of the event handler.

.

The HandleExternalEventActivity activity is used in conjunction with the CallExternalMethodActivity activity for input and output communications with a local service. You can use these activities directly for generic communications. Or, you can subclass the HandleExternalEventActivity and CallExternalMethodActivity classes to create activities that are strictly bound to specific events and methods on an interface that is attributed with the ExternalDataExchangeAttribute attribute.

.

The base HandleExternalEventActivity class blocks the workflow until the event specified by the InterfaceType and EventName properties is raised by the corresponding local service registered with the WorkflowRuntime. After the event is raised, or if it was raised before the activity started executing, the inbound data is assigned to bound locations as defined in the ParameterBindings collection.

.

For more information, see the HandleExternalEventActivity class, GeneratingCommunicationActivities, and UsingLocalServicesInWorkflows.

.

For code samples that demonstrate how to use the HandleExternalEventActivity activity, see RaiseEventToLoadWorkflow and CorrelatedLocalService.

.
      HandleExternalEventActivity
.

The above workflow is a common pattern for replicated user tasks. The CallExternalMethodActivity notifies the user of the task and the HandleExternalEventActivity gets an event when the task is complete. Let's say that we're going to assign 3 tasks for UserA, UserB, and UserC so our replicator will initailize itself with the collection {"UserA", "UserB", "UserC"}. Assuming that the user name is the correlation parameter, our ChildInitialized handler might look like:

.

| HandleExternalEventActivity(1)

.

| HandleExternalEventActivity(2)

.

| HandleExternalEventActivity(3)

.
          HandleExternalEventActivity(4)
.

This tool creates derived types from CallExternalMethodActivity and HandleExternalEventActivity.

.

The QueueName property can actually return an object of type EventQueueName when using an HandleExternalEventActivity.