Parallel activity example

Please share one small demo on how to use parallel activity. Please share if and XAML is available.

1 Like

There used to be some bugs with this have they been resolved now?

@andraciorici

Example for Parallel Activity in UiPath
Parallel.xaml (11.6 KB)

Regards,
Poovarasan Guna.

1 Like

“The ParallelActivity activity lets you schedule two or more child SequenceActivity activity branches for processing at the same time. Although branch SequenceActivity activities are scheduled to start processing at the same time, they do not start processing at the same time. Processing begins with the execution of one activity that is contained in one of the SequenceActivity branches. When that activity is completed, the next activity in sequence in another branch executes, and so on. Activity execution switches between the SequenceActivity branches, with one activity executing at a time until all the SequenceActivity branches finish executing. This completes the processing of the ParallelActivity activity. ParallelActivity does not guarantee the exact order of execution across the SequenceActivity branches.”

An excerpt from the MSDN site says that, the activities within each sequence are completed one after the other i.e. Activity 1 starts inside sequence 1, and then the control switches to Activity 1 inside sequence 2 until Activity 1 is completed inside all sequences. But according to the workflow made by @Poovarasan2, all the three notepad TypeInto activities complete in the same time. Is my understanding wrong somehow?

2 Likes

Hey @ankwoods

Your understanding is correct and that is also correct what MSDN article says.

Here You are not able to detect the difference because of the Type Into Activity with Simulate property checked.

if you will check simulate of the Type into Property.it simulates the type using the technology of the target application. This input method(Simulate) is the fastest of the three(Default, Simulate type, Window Messages) and works in the background. By default, this check box is not selected. If neither this nor the SendWindowMessages check boxes are selected, the default method performs the click using the hardware driver. The default method is the slowest, it cannot work in the background, but it is compatible with all desktop apps.

You can give it a simple try with simple write line activity as well with different Text . then you will observe what MSDN says. Once it will complete first sequence of parallel then it will move to next.
Or it can jump to the next also if you will use with invoke with isolated.Check it here. This is all about operating system Context switching as per Round Robin Algo on a single CPU.

If you will pass more activities after type into in the same sequence you will observe the behavior. :slight_smile: What MSDN Article States.

Regards…!!
Aksh

5 Likes

I want to quickly explain how I used this activity, if you run into something similar in the future or someone else is going through this thread latter.

I had an excel macro that was bringing up a VB message box as soon as the file was being opened. I used Parallel Activity to open the excel word book, using Read Range Activity on the right side of the parallel window and Click Activity on the left, which clicked “ok” on the message to make it disappear. Please note this was not possible before hand, as UIPath is inconsistent when it came to do this.

Hope this helps someone else as well!

4 Likes

Thanks a million @aksh1yadav

One more scenario while using agent assisted automation, we want to execute two event based on two different triggers, we can use parallel.

hi go here for understanding parallel watch part 1 and part 2

Hi Akshay ,

As we had discussion early regarding parallel activity. you just told me that it will start executing the code from right side to left side .
but As per my understanding it will start running the sequence from left side to right side .

please find the sample xmal

Thanks
Vijay Bharti

Parallel.xaml (9.9 KB)

2 Likes

Hi @VijayBharti

If you remember my exact words then i was telling you about the execution flow with Runtime behavior.
So suppose their is one Parallel Activity we are using with 3 sequences like Sequence1, Sequence2, Sequence3.

Now the Parallel Activity has only 3 childrens.It schedules Sequence 1, Sequence 2 and Sequence 3 and then they are executed as they pop off the Stack.

So here is the fact for you which i was saying( i was thinking you are aware with a basic behavior which everyone can observe by studio after running but things like how it happens in the background, so i was telling you :slight_smile: it will pick up sequence from Left to right so first Stack item will be Sequence3,then second one will be Sequence2 then Sequence 1.

Now it will pop up the Top Element from Stacak that is Sequece 1 and will Execute it. then 2nd one and so on.This is how works.

To be Honest it does not use only Stack their is we can say a combination of Queue and Stack because their is some chances like one of the activities in the sequence can go idle then Sequence will be blocked by a pending bookmark so control will pass to the next Sequence until all the Sequences are blocked waiting for a bookmark.

Note - Now you might come with one question how you can make a sequence to go in a idle state with a bookmark so simple just use Delay.

Parallel Activity follows a very simple pattern.It schedules it’s child activities and then it allows the child activities scheduling to do their task they suppose to do.

The interesting thing about parallel is Parallel doesn’t care how the child activities schedule their children.

Regards…!!
Aksh

1 Like

@aksh1yadav .

Based on what i heard from you side,i just gave the explanation but after reading your above comment i am also agree with this fact . :grin:

Thanks & Regards
Vijay Bharti

Hello,

Check this, it might help :wink:

A Parallel activity operates by simultaneously scheduling each Activity in its Branches collection at the start. It completes when all of its Branches complete or when its CompletionCondition property evaluates to true . While all the Activity objects run asynchronously, they do not execute on separate threads, so each successive activity only executes when the previously scheduled activity completes or goes idle. If none of the child activities of this activity go idle, this activity execute in the same way that a Sequence activity does.

1 Like

return new Parallel
{
// Timeout from branch causes other branch to cancel.
CompletionCondition = true,

Branches =
{
    // Delay Branch
    new Sequence
    {
        Activities =
        {
            new WriteLine { Text = "Branch1: Body is about to Delay 2secs transferring execution to Branch2" },
            new Delay
            {
                Duration = TimeSpan.FromSeconds(2)
            },
            new WriteLine { Text = "Branch1: Body is about to complete causing Branch2 to cancel.." },
        }
    },

Hi
This process opens 4 browsers one by one and aligns them into 4 corners of the screen.Then a parallel activity is run to type into browser, get text and write line.

Note 1-
You will notice that the parallel activities wait for system resources to type/get text.
If you run in normal mode -
the texts ‘amazon stock price’ and ‘microsoft stock price’ seem to get entered at the same time because ‘Simulate type’ is ticked for those 2 type into activities.
However if you run this in the debug mode, even those 2 texts are being entered one by one.

Note 2-
In the Properties panel of the Parallel activity, if you set the ‘Condition’ parameter as True then the process will end as soon as one of the sequences finishes and will not continue to run the other sequences of the parallel activity.

ParallelActivityTest-FourBrowsers.xaml (34.4 KB)

1 Like

Hi Poovarasan,

I am trying to define logic for completion of inventory processing in given SLA(i.e. 10 Mins). However, we do not find any activity or workaround to do so, I am trying to achieve this by putting parallel processing where First activity will process the inventory and the second will wait for SLA. If any of them has completed there execution, we mark SLA completed for given inventory.

My problem comes up when the given Uipath Parallel activity is not processing as same as expected.( it will run the activity 1 to its completion and then it will start processing activity 2).
Please look at the screenshot.

Sequence.xaml (9.3 KB)