Task 5: Define the OrderProcessing State
In this task, you add the child activities that are required to define the OrderProcessingState
. When this state is entered in the state machine workflow, the order has already been submitted by the Simple Order Form host application, and the WaitingForOrderState
has processed this order. The last activity in the WaitingForOrderState
was a SetStateActivity that sets the current state of the state machine workflow to the state that is defined in this task, the OrderProcessingState
.
Note
Although you are encouraged to follow the exercises in a linear manner, it is not required. You can start this exercise by opening the sample project and proceeding to the steps in the following section.
To create activities and fields required for the OrderProcessingState
In the
OrderProcessingWorkflow
designer, define the following child activities.Type Name Location Parameters initializeOrderOpenStateActivity
OrderProcessingStateActivity
invokeProcessingNewOrderStatusUpdate
initializeOrderOpenStateActivity
- InterfaceType: IOrderingService
- MethodName: ItemStatusUpdate
CallExternalMethodActivity
invokeOrderProcessedStatusUpdate
initializeOrderOpenStateActivity
- InterfaceType: IOrderingService
- MethodName: ItemStatusUpdate
SetStateActivity
setStateActivityOrderCompleted
initializeOrderOpenStateActivity
- TargetStateName: OrderCompletedStateActivity
The workflow should now look like the following in the designer.
When the state initialization activity is expanded, the designer should look like the following.
- InterfaceType: IOrderingService
To define the CallExternalMethod methods that calls and finalizes the new orders
Create a new private method named
ProcessNewOrder
that accepts an Object method namedsender
and an EventArgs object namede
.In the
ProcessNewOrder
method, set theitemStatus
field equal to the valueProcessing order
.private void ProcessNewOrder(object sender, EventArgs e) { this.orderItemStatus = "Processing order"; }
Create a new private method named
FinalizeOrder
that accepts a Object method namedsender
and an EventArgs object namede
.In the
ProcessNewOrder
method, set the_itemStatus
field equal to the value,Order processed
.void FinalizeOrder(object sender, EventArgs e) { this.orderItemStatus = "Order processed"; }
Compiling the Code
For more information about compiling your code, see Compiling the Code.
For a finished version of the tutorial, see Completed State Machine Workflow Tutorial.
See Also
Concepts
Windows Workflow Foundation and Application Communication
State Machine Workflows
Other Resources
Tutorial: Create a State Machine Workflow
Communications
Host Communication Sample
Ordering State Machine
Simple State Machine
Copyright © 2007 by Microsoft Corporation. All rights reserved.
Last Published: 2010-03-04