Activities |
Describe |
Designer appearance |
Collection Management |
Addtocollection<t> |
Add Item to collection. |
|
Removefromcollection<t> |
Remove item from collection. |
|
Clearcollection<t> |
Clears the collection and removes all of the child items that are stored in it. |
|
Existsincollection |
Verify if the item exists in collection. If a subkey exists, the active result parameter is assigned to TRUE. |
|
Flow control |
If |
An If activity executes a child activity based on a Boolean expression.
If the Boolean expression-condition evaluates to True (and the then activity is configured), the execution of the then activity is scheduled. If the expression evaluates to False (and the else activity is set), the else activity is evaluated. |
|
Dowhile |
Repeatedly executes its body until Condition evaluates to True. The body is executed at least once. |
|
Foreach/foreach<t> |
A foreach activity contains a list of values and a body. At run time, the list is cycled, and the body is executed once for each value in the list. |
|
Pick |
The pick activity provides an event-based flow control model in WF. Pick the only valid child activity is pickbranches.
When pick begins execution, all trigger activities of its branches are scheduled to execute. When the first trigger completes the corresponding action activity it plans to perform, all other trigger activities will be canceled. |
|
Pickbranch |
Pickbranch represents a branch of the pick activity. It is made up of trigger and action. Pickbranch can only be added to the pick activity. |
|
Sequence |
The sequence activity allows one or more activities to be executed in order. |
|
Switch<t> |
The switch activity is similar to the C # switch statement. It contains a expression and a set of cases (each case has a key and an activity). When the expression is evaluated, the switch activity looks for the case that matches the result of the expression and, if found, executes the activity associated with the event. |
|
While |
When the Boolean type condition evaluates to True, the while activity executes its body. |
|
Parallel execution |
Parallel |
The parallel activity allows its child activities to execute in parallel. It schedules the execution of each workflowelement in its branches collection at the start of execution. When all branches are complete or their Completioncondition property evaluates to True, it completes execution. |
|
Parallelforeach/parallelforeach<t> |
The Parallelforeach activity traverses its set of values and merges it into each element of the collection by performing a activities that resemble foreach. The main difference is that the embedded statements are executed in parallel mode.
Like parallel activities, Parallelforeach also has a completioncondition, so the Parallelforeach activity can be completed ahead of time, provided that Completioncondition returns True. The completioncondition is calculated after each iteration completes. |
|
Error handling |
TryCatch |
The TryCatch activity is similar to a try in C #. Catch structure: All activities in a try block are executed, and if an exception occurs, the most matching catch block is scheduled to be executed (if no matching catch is found, the workflow is interrupted). All catch blocks are located in a collection named catches.
The Trycatch activity also has a finally block that will be executed after the try (and the catch that may be executed).
Tips on exceptions that are not handled:
TryCatch provides an exception handling mechanism at the workflow level. When an unhandled exception is thrown, the workflow is interrupted so that the finally block is not executed. This behavior is also the same as try in C #. The catch structure remains consistent. |
|
Catch<t> |
Represents a catch in the trycatch activity. If an exception is thrown in the try element, Trycatch attempts to find a matching Catch element based on the type that throws the exception.
Catch<t> can only be used in trycatch activities. |
|
Throw |
The Throw activity throws an exception in the workflow. The Throw activity contains a exception property that contains an exception that will be thrown at execution time. |
|
Practical Tools |
Assign |
The Assign activity assigns the value of its values parameter to its to parameter.
The types of the two parameters must be compatible. This compatibility is validated during run time. |
|
Delay |
The delay activity, as the name suggests, blocks the execution of the current workflow for a period of time that is specified by the user through its duration parameter. After the delay expires, the workflow continues to execute. The delay delay should be set to a TimeSpan value. |
|
Invokemethod/invokemethod<t> |
InvokeMethod is an activity that allows us to invoke an existing CLR method and a static method. To invoke a method, all we need to do is provide owner information for the method (static method is TargetType, instance method is TargetObject), MethodName, and parameters of the method.
InvokeMethod supports the following methods to invoke the scene:
Common instance methods and static methods
Parameters passed by value or reference
Support for parameter arrays
Support for generic parameters
Asynchronous method call |
|
WriteLine |
Outputs the text to the configured output console.
Output to the back of the System.Console:
WriteLine has a TextWriter parameter that can be configured for different outputs. For example, we can configure the TextWriter property to send text to a asp.net page. If TextWriter is not set, its default value-system Console is selected. |
|
Advanced (cancellation, compensation, transactions, and persistence) |
Cancellationscope |
The Cancellationscope activity consists of two main sections, body and Cancelhandler. The body includes activities that are normally performed. If the activity is canceled, the Cancelhandler is executed. |
|
Compensatableactivity |
Compensableactivity is used to define a potentially long-running activity, along with compensation and confirmation logic.
Compensation allows the user to specify activities that perform corrective actions that will be executed after the body completes successfully. |
|
Compensate |
Compensate is used to explicitly invoke the Compensableactivity compensation handler. |
|
Confirm |
Confirm is used to explicitly invoke a compensableactivity acknowledgment handler. |
|
Persist |
Persisting workflow instances. The persistence of the workflow is accomplished based on the configuration of the workflowinstancethe in execution (this activity does not contain any parameters). |
|
TransactionScopeActivity |
TransactionScopeActivity provides a complete operation to initialize a new transaction, build a transactional environment (a workflow execution property), and invoke the transaction after the body of the TransactionScope activity completes.
TransactionScopeActivity supports the "requirement" semantics. If an environment transaction is already in use, a new transaction is created.
Nested transaction scope
TransactionScopeActivity can be nested in another transactionscopeactivity. A transactionscopeactivity that is nested in another transactionscopeactivity will use an existing transaction. |
|