Understanding of the copy of the activity

Source: Internet
Author: User

Before reading this article, read the blog of WF wxwinter: Workshop.

Repeat wxwinter's blog post:

While and replicator can re-execute its sub-activity, while and replicator do not reset it to the Initial State each time they reuse the activity. Instead, the original activity is cloned, and each cloned activity is managed separately. It does not interfere with other cloned activities. Each cloned activity must have its own AEC to manage the status.

There is no problem with this description. I haven't made it clear for two reasons:

1. Visibility of the cloned activity.

2. When will the activity be cloned.

 

Let's start with wxwinter's example 2. The root cause of failure in achieving the expected goal is the visibility of the cloned activity.

In example 1, you can perform ++ operations on the myproperty attribute of the active instance in the process. In the process, you can only see the real active instance of activity1, and it is impossible to see a copy of the activity, therefore, the ++ operation is targeted at the real activity1 activity instance. In Example 2, because the ++ operation on the myproperty property of the active instance is blocked in activitylibrary, The ++ operation during running is performed on the copy of the activity, so it does not affect the real active instances.

We often need to block the activitylibrary comrades to pay attention to the need to use this. parent. getactivitybyname (this. name) to get the real activity instance. getactivitybyname is used to return the activity instance of the current activity and its sub-running activity based on the specified type name.

Question 2: When to clone an activity? In a serial condition, clone the activity before each execution sequence. The evidence is used in the copy activity.Code:

Private void codeactivityappsexecutecode (Object sender, eventargs E)
{
Activity1 a1 = This. Parent. getactivitybyname (this. Name) as activity1;
A1.myproperty ++;
Console. writeline (myproperty );
}

The myproperty value of the copy is also changed.

In parallel, all the data is cloned at the beginning.

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.