Summary of WF learning notes (1)

Source: Internet
Author: User
Recently want to learn something WF, read the WXWinter blog http://www.cnblogs.com/foundation/category/215023.html

This article is mainly for you to review.

1. WF projects include four:

Activity Designer Library

Activity Library

Workflow Console Application

WCF workflow service Application

2. The Activity file uses the xaml format.

3. Tree Structure of branches and leaves during WF activity. FlowChar and Sequence are two common direct points.

4. WriteLineActivity is a common Activity. Note that its TextWrite attribute allows us to use our own TextWrite class, as long as it inherits System. IO. TextWriter.

5. You can use the ActivityXamlService. Load (Stream stream) method in the code to Load an Activity.

6. You can inherit the CodeActivity class to implement your own Activity. The override Execute method is required.
7. You can set Variables in the Activity by using Variables. Variables can be used in their respective applicability.

8. You can use Arguments to set inbound and outbound parameters. Here, In is input, out is output, InOut is equivalent to ref, and Property is attribute (ActivityAction and ActivityFunc can be used ).

1) The. In parameter uses Dictionary <string, object> to pass in and out. In parameters are not changed externally.

2) The Out parameter is obtained using the Completed (WorkflowApplicationCompletedEventArges e) {string outArg = e. Outputs ["ArgName"]. Tostring ()} method.

9. Several Basic control flow activities

If Swith <T> While DoWhile Foreach <T>

10. Parallel container Pick and PickBaranch trigger container (this will only trigger one PickBranch content) ParallelForEach <T> Loop

11. Collection operations. SortedSet is recommended for complex object Collection operations. <T>

1). AddToCollection <T>

2). RemoveFromCollection <T>

3). ClearCollection <T>

4). ExistsInCollection <T>

12. Operation on the set of key-value pairs. SortedList <K, V> is recommended.

13. A production mode and process end mode of WF

WF exceptions can be generated in the following ways:

1). Throw an exception using Throw Activity (the exception will not be broken out)

2). Code running error (it will be disconnected from the exception)

WF process end method:

1) if the WF instance has no problem during running, the ActivityInstanceState changes from Executing to Closed.

2). If the process

Terminate method called

Encounter TerminateWorkflow Activity

WorkflowApplication. OnUnhandledException is not used when an exception occurs.

Specify UnHandledExceptionAction. Terminal when an exception occurs

In this case, the ActivityInstanceState is changed from Executing to Faulted.

3). If the process

Canceled method called

Specify UnHandledExceptionAction. Canceled when an exception occurs.

In this case, the ActivityInstanceState is changed from Executing to Canceled.

4). If the process

The Aborted method is called.

Specify UnHandledExceptionAction. Aborted when an exception occurs

When these conditions occur, the process fails and Aborted is penalized. The failed process does not have the ActivityInstanceState instance status.

5) ActivityInstanceState: Closed, canceled, and faulted indicate that the process has ended and the Completed is penalized.
6) ActivityInstanceState Aborted, the process will disappear instantly, trigger the instance's Aborted, does not trigger the instance's Completed.

14. You can use TryCatch and Catch <T> to Catch exceptions. You can use Rethrow to throw an exception again.

15. You can use terminalActivity to end the process, but the status is Fault.

16. CancellationScope cancels the container. If it is normal to run to the CancellationScope container, it ends normally and the state is closed. If an internal exception occurs and OnUnhandledException returns Cancel, the cancelledsled container is called and the State is Cancled.

17. Use CancellationScope in Parallel. When the CompletionCondition of parallel is True, the CancellationScope of one minute is triggered, and the process is ended and the result is Closed.

18. InvokeMethod call method.

Static Method: Fill in the static class in TargetType, and fill in the static method in MethodName. Write the in, out, in/out parameters in parameters. Write the return value variable in Result. You can also call generic methods.

Instance method: you only need to provide an instance of the class in TargetObject.

19. WF instances run in a single thread. You can use Depay Activity to wait the thread. Note: Delay is not Thread. Sleep, and Parallel is run by a single Thread.

 

1) if a Parallel consists of two branches, each of which has a Thead. Sleep (10000), the result is delayed for 20 seconds. This indicates that parallel runs in a single thread.

2) if a Parallel has two branches and each branch has a Delay for 10 seconds, the result is delay for 10 seconds. This indicates that Delay is specially processed.

20. WorkflowInvoker is single-threaded and WorkflowApplication is multi-threaded.

If a WorkflowInvoker simultaneously Invoke two activities, the result will be

If a WorkflowApplicationi loads two activities at the same time, the result will be

21. InvokeMethod call the Asynchronous Method

1. Set the RunAsynchronously attribute of InvokeMethod to True.

2. The following two methods are required;

1). IAsyncResult Begin [historical method] ([historical method parameters], AsyncCallback callback, object asyncState)

Void End [original history method] (IAsyncResult r)

2) When the [RunAsynchronously] attribute is set to [False], [InvokeMethod] calls the [historical method]

3) when the [RunAsynchronously] attribute is set to [True], [InvokeMethod] calls the corresponding [Begin original history method] and [End Original history method] Methods

4 ). if [Begin original history method] and [End Original history method] are not provided, [InvokeMethod] ignores the value of the [RunAsynchronously] attribute.

The [Begin original history method] and [End Original history method] of the MethodName attribute are not called. The [original history method] is called.

22. If you want InvokeMethod to call the Asynchronous Method and wait until the Asynchronous Method is completed before the process continues to be executed, you need to return False for the CompeltedSynchronously attribute of the IAsyncResult interface.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.