Asynchronous Calls

Hi, good afternoon.

Is it my impression, or Extension methods are called in an Asynchronous way? For instance, I'm using LeoContactList to read the phone's contact list, but if I have a message before reading the contacts and another after reading the contatcs, they are both written before the contacts are read.

It is more likely the order and positioning of your blocks.

Show your relevant blocks, it will make it easier for others to help.

1 Like

image

Something as simple as this...EscreveLog is a function that writes the App logs to a file...but what I get in the file is:
1
2
Ant then all the Logs generated in the
image

event.

You call the contact list, then in the GotContactList event you create your logs. You won't have the new contact details where you have this block placed.

image

Do things like this

image

1 Like

Yes, I know that.

My point is that the code does not wait for "GotContactList" to finish before continuing the execution of the

image

Block.

Why, therefore, do you expect what you are doing to work?

Calling the contact list is completed in the gotcontactlist event, it is not completed and therefore the output cannot be used in the way you have your blocks.

To answer your original question, if an extension performs a function that returns its output to an AfterFunction event, then yes, it is usually asynchronous. But this is not always the case, and depends on the work any extension component is performing.

Event-Based programming in AI2 - FTurbak
CCSCNE14-AI2-events-first-paper.pdf (432.1 KB)

1 Like

yes exactly...
this is the "secret" of asynchronous processing, see also The model of event processing in App Inventor by Lyn

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by icon24 Taifun.

2 Likes

Thanks Taifun.

That was the understanding that I had, but I wanted to confirm.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.