Understanding threading in Ignition

Hi all,

I'm currently working on understanding the basics of threading in Ignition. My question is as follows: Is there a way to have certain threads always treated as a part/portion of the main thread in a mobile OS?

Specifically, when I have my app running and open on my device it will correctly to perform both intake and to render points of interest (Geo-location data). However, when it is closed and running as a background thread it seems to only partially work as intended.

If this is possible, how would I go about creating a function to do this? And where would be most ideal to place it?

If this idea will only lead me down a rabbit hole of suffering and there is a better solution I'd be very grateful to hear it.

Thank you,

Cam

If you are using perspective then none of the threads are actually executing on your mobile device, they are running on the Ignition gateway. They are (mostly) async threads already.

What do you mean when you say 'intake' points of interest? Are you passing a file or something to your session/app for ignition to parse and pull the data out of? How are your existing points of interest pulled into the session/map component?

What do you mean it only partially works as intended? Does it not import any points? Does it only import some of the points of interest? What part works? What part doesn't work? Walk us through the expected process flow and then what actually occurs.

How are you starting the process in a 'background' thread? Are you just starting an upload/intake then closing the app/pushing app to background? What happens if you command the view to refresh after closing and then re-opening the app?

As Ryan noted, none of Ignition's threads (proper) are running in the mobile OS. Only the mobile app, a thin wrapper around the mobile OS's browser, is actually running in your mobile device. Mobile devices typically force apps to sleep when they are not in the foreground, for battery life maximization. You will need to play with your Mobile OS's battery saver settings--to let Ignition's app run in the background.

I am using perspective. That would make a lot of sense

When I say points of interest I mean longitude and latitude values that are only accessible from the perspective session properties, that via change script on a timer, are pushed into a database to be plotted on the map component.

The result of this when the app is open is that it pushes and plots the points correctly and at a fast enough rate to create a comprehensive line that follows the user.

When the app is not open and, in my pocket for example, it will pull and post data only occasionally, leading to some very strange lines being plotted on my map that indicate my user drove through several homes even though they were on the road the whole time.

I did try creating a refresh function and forcing the app to refresh to see if that would fix it and it did not, unfortunately. Yes, just starting the app and letting it exist as a process on my phone.

Is there a way to force it to not sleep via ignition functions? (aside from refresh because that does not seem to work for this)

Sounds like what pturmel mentioned, your phone's os is likely forcing the app to sleep.

1 Like

No. That would be something malware does (or wants to). So don't hold your breath waiting for this. Just see what you can do with your mobile OS settings.

1 Like

That's what I was thinking when I asked about the force no sleep, but you never know, weird things exist :sweat_smile: