Race conditions in Tasker? I'm trying to learn Tasker, and it seems that it runs its steps asynchronously, so I end up with a race condition where my task doesn't have the data it needs to continue. I made a simple pair of tasks to test. (Hardware info: LG G2 on Verizon running stock KitKat ROM, rooted.)

Task 1: Echo


Variable Set: [Name: %ret; To: %par1]
Flash: [Text: Par1 = %par1]
Return: [Value: %ret; Stop: On]


Task 2: Echo Test


Perform Task: [Name: Echo; Priority: 2; Parameter 1 (%par1): 5; Return Value Variable: %var]
Variable Set: [Name: %dbl; To: %var * 2; Do Maths: On]
Flash: [Text: %var * 2 = %dbl]


Expected output:


Flash: "Par1 = 5"
Flash: "5 * 2 = 10"


Actual output:


Flash: "%var * 2 = 0"
Flash: "Par1 = 5"


My question is, why doesn't Tasker wait for step 1 to complete before continuing on to step 2? In fact, I'm not even sure it's working correctly in the first place. In my Echo Test task, I added a 2-second wait after calling the Echo task, and now my output is this:


Flash: "Par1 = 5"
Flash: "%var * 2 = 0"


So the %var variable doesn't seem to get set at all. Am I doing something wrong, or is my Tasker installation bad?
There are 2 potential solutions.

One, when you use "Perform Task", you can pick the priority of the task you're asking it to run. If you set the priority the same or higher than the current task (a good way to do this is to specify %priority + 1), the new task will completely execute before the current on resumes. If you set the priority of the task lower than the current task's priority, the current task will finish before the new task starts.  

Since I've had mix results with the use of priority, you could add a "Wait Until" after the perform task. Example:

1. WAIT UNTIL
      MIN: 1
      UNTIL: %Done IS SET


The variable, %Done, is set at the last line of the task you called. You can set %Done to anything but one it is set the 1st task will know it is okay to continue.