I have a system I created with two views. On the first view is a table, and when a row is selected and the
Edit button is clicked, a new view pops up with the selected row data passed in as a parameter. On the second view is a form and another table. Users enter information into the form, which adds a new row to the second table. Also on the second view is a
Complete button, which takes every single row in the second table and inserts it into a database through an API (to an onsite webserver). On a successful insert, the second view closes, and the items appear in a row subview (if expanded) of the first table.
The problem is, if the second table has more than about 5 entries in the table, the UI lags considerably. For instance, a user reported that when they had 10 entries, the UI didn’t respond for 15 seconds. This is very inconvenient.
I would like to insert the records asynchronously, so that the popup view closes and then the necessary data is inserted when available. I used the
system.util.invokeLater functions in Vision projects before, but the scope for the
invokeLater function is listed as Vision only. Here is the example listed in the documentation:
def longProcess(rootContainer = event.source.parent): import system results = ...( something ) def sendBack(results = results, rootContainer = rootContainer): rootContainer.resultsProperty = results system.util.invokeLater(sendBack) # only valid for Vision scope? system.util.invokeAsynchronous(longProcess)
This example doesn’t work with a Perspective session. How would I call a function asynchronously in a Perspective session? Also, is a new thread created on the Ignition server for every individual session?
A few more things to note: the API is third-party, something I have no control over. There is no batch insert, so I iterate over every row in the second table manually. Also, when I use Postman or
curl to insert, the time to insert a single record takes about ~250ms.