Learn About Microsoft .NET Framework 3.5
By Certification Magazine —
1 | 2 | 3 | 4 |
You should not create a class derived from the SequenceActivity class because this technique will result in more developer effort than required for a simple workflow activity. You should derive from the SequenceActivity class when creating a custom composite activity in which each child activity must be scheduled in a linear fashion, one after the other. In this scenario, you do not have any child activities, so you should derive from the Activity class to minimize developer effort.
You should not override the OnStatusChanged method to perform work within a custom activity because this is the default event handler associated with the StatusChanged event. The StatusChanged event only indicates the activity runtime has changed, providing an ActivityExecutionStatusChangedEventArgs.ActivityExecutionStatus property.
The status indicates whether the activity has been initialized, is executing, cancelling, compensating, faulting or has closed. You should override the Execute method and provide the value for execution status to indicate the work a custom activity should perform.
References:
Objective: Apply rules and conditions.
Sub-objective: Write rule sets.
Multiple answer, multiple-choice
In a Windows Workflow Foundation (WF) application, you are defining a declarative rule condition using the Microsoft .NET Framework 3.5. The rule will be used in a workflow that maintains stock inventory for an office supply warehouse.
You need to define a rule to verify that the stock level of a product has not fallen below the product's defined reorder point. If a product's stock level is lower than the reorder point, the product should be reordered to replenish existing supplies. Product reorders also are dependent upon the stock priority level. The stock priority level for a product is a public field in the workflow. The field uses a value in the PriorityLevel enumeration.
Which expression classes should you use to reference the stock priority level? (Choose two. Each correct answer is part of the complete solution.)
A. CodeIndexerExpression
B. CodeDefaultValueExpression
C. CodeTypeReferenceExpression
D. CodeTypeReferenceExpression
Answer:
C, D
Tutorial:
You should use the CodeTypeReferenceExpression and CodeFieldReferenceExpression classes to reference the stock priority level. The CodeFieldReferenceExpression and CodePropertyReferenceExpression classes refer to fields and properties associated with an object, respectively.
In this scenario, the stock priority level is a public field that uses a custom enumeration. To reference the field, you should use the CodeFieldReferenceExpression class and to reference the value, you need to specify the enumeration with the CodeTypeReferenceExpression class. The CodeTypeReferenceExpression class refers to a data type and is required for non-primitive types. You would use the CodePrimitiveExpression class to refer to primitive data types.
You cannot use the CodeIndexerExpression class to reference the stock priority level because it is not an indexer. You would use the CodeIndexerExpression class to reference a non-array indexer associated with a class or object.
You should not use the CodeDefaultValueExpression class to reference the stock priority level because you need to compare the actual value of the stock priority level, not its default value. You would use the CodeDefaultValueExpression class to create default values for data types.
References:
Objective: Manage transactions and compensations.
Sub-objective: Perform exception handling.
Single answer, multiple-choice
You are using version 3.5 of the Microsoft .NET Framework. You use the following code to instantiate a Windows Workflow Foundation (WF) runtime for sequential workflows:
using (WorkflowRuntime wfRuntime = new WorkflowRuntime()) {
//Instantiate and run workflows
}
You want to handle any exceptions that are thrown by workflows using the runtime. What should you do?
A. Add an event handler for the runtime's WorkflowTerminated event.
B. Add an event handler for the runtime's WorkflowAborted event.
C. Add an event handler for the runtime's WorkflowSuspended event.
D. Start each workflow within a try...catch block, specifying the System.Exception exception.
Answer:
A
Tutorial:
To handle any exceptions thrown by workflows in a runtime, you should use the WorkflowTerminated event. The WorkflowTerminated event is raised by a TerminateActivity activity or is raised when an unhandled exception is thrown in a workflow. You would use the following code to create an event handler for the WorkflowTerminated event:
private void handleExceptions ( object sender, WorkflowTerminatedEventArgs e ) {
//Handle exceptions
}
You should not add an event handler for the runtime's WorkflowAborted event because this event is raised when a workflow is stopped in the middle of processing and not necessarily when unhandled exceptions are thrown. Unlike .NET exception handling, the WF runtime schedules exceptions in a queue so that the workflow can continue execution to the next available activity. A WorkflowAborted event would be raised only when a workflow is explicitly aborted by the workflow host or if the workflow runtime cannot terminate the workflow.
You should not add an event handler for the runtime's WorkflowSuspended event because this event is raised when a workflow is paused but still resumable, not when an unhandled exception is thrown. The WorkflowSuspended event is raised by the workflow host or by a SuspendActivity activity explicitly, or by the workflow runtime when dynamic changes are being applied. An exception would not suspend a workflow.
You should not start each workflow within a try...catch block because although this technique will catch workflow framework errors, it will disrupt the workflow host logic. It is a recommended approach to handle events explicitly if possible, rather than use the overhead exception handling. You should use the WorkflowTerminated event to handle exceptions thrown by workflows.
1 | 2 | 3 | 4 |



