Accessibility

Table of Contents

User experience considerations with SQLite operations

Database operation time

Although one of the primary differences in the two execution modes is the programming model used to work with the SQLite database, the primary consideration in deciding which execution mode to use is the total time that operations against the database take to complete. The longer a database operation takes to complete, the bigger impact the choice of execution mode can have on the user experience. Before we dive into the distinctions further it is important to understand a little about the Adobe AIR runtime.

The Adobe AIR runtime uses a single application thread. What this means is that when code that you have written is being executed, other application tasks like screen updates or user gestures like button clicks are ignored. If you've ever written a loop that took a really long time to run, you probably noticed that the rest of the user interface stopped responding until the loop finished. If your application has effects that play having the user interface jitter can make for a degraded user experience.

Although there is only a single application thread, there are multiple system threads. System threads handle low-level tasks like loading an image or accessing a web service. In the case of Adobe AIR, a system thread handles processing operations against a SQLite database. System threads operate in the background, which means that it is possible for a database operation to be processing at the same time the application code is playing effects or responding to user gestures. With that quick primer, take a look at the two execution modes and how they handle the total time a database operation takes to complete.

With a synchronous connection, the application thread pauses while waiting for the system thread to complete the requested database operation. Since that database operation is pausing the application thread, effects will not play and user gestures will be ignored until the operation completes. Thus the longer a database operation takes, the more the impact on application responsiveness increases. If a database operation takes three seconds to complete, the application would be unresponsive for that entire time. No screen updates, no user gestures, and so on.

An asynchronous connection, on the other hand, will cause a system thread to start the database operation and then immediately continue to execute the application code. In this case the application can go back to responding to other user gestures or playing effects. Since the database operation is happening in the background, the length of time it takes to complete will have no impact on the user interface responsiveness. If a database operation takes three seconds to complete, the application may slow down a little as the database operation executes in the background, but it will remain responsive.

The lack of user gesture processing on a synchronous connection also means that the user can't cancel the operation, nor can the user be given any indication of how much time the database operation will take to complete. For this reason, understanding how long database operations will take, and how responsive the user interface should be when performing those actions, should be the primary consideration when deciding what type of execution mode to use.