Salesforce

How Do I Manage Communication Between Parallel Tasks? (Magic xpa 3.x)

« Go Back

Information

 
Created ByKnowledge Migration User
Approval Process StatusPublished
Objective
Description

How Do I Manage Communication Between Parallel Tasks? (Magic xpa 3.x)

Because parallel tasks run in separate spaces, you cannot pass parameters directly between them, or store data in the Main program. So, in order to “call” a parallel task, you post an event to it. The event can have parameters to pass data into the parallel task. Here is how you do it.

Prerequisite: You have to know the context id of the program you are trying to communicate to. See How Do I Retrieve the Context ID of a Called Parallel Program? for how to do that.

  1. Set up a global event that has the parameters you need to pass between the programs. In our example, we set up an event called “ge.Receive”, that has one parameter, the message we want to send. Note that Wait must be set to No.

  2. In the first program, raise the event, sending the parameter, as shown here. You must set Wait to No or you will get an error when you try to turn it.

  3. In the Event Properties, set the Destination context name to the name of the context you are communicating to. Most of the time this will be some long alpha number string generated by Magic xpa, such as ‘1493034580378080’ in our example. However, there is also the Main context (called ‘Main’) and contexts can be renamed to any string if you like.

Now, when the event gets raised, it will not be raised in the current context, but in the other context. Note that this gets a little confusing. In this instance, we are raising a ge.Receive event while we are trying to send a message.

What happens in the other context is that the event gets raised, and it does the appropriate processing. The receiving task doesn’t know the origin of the event that sent the data, nor does it need to. The message arrives and is displayed.

However, if this task also needed to send data back to the sending program, then it would have to know the context name of the sending program, to reverse the process. This could be done by simply using an additional parameter in the event, which would contain the context name of the sender.

See also

The Online Samples project (program MT05)

Reference
Attachment 
Attachment