I am working on an web app that will eventually run on a Raspberry Pi and read electric submeters on a defined schedule. All the meter reading routines are in the app and there are web pages for the user to configure the system and tell the app when to read the meters. When the user updates the schedule, the program updates the SQLite database using a connection in the session. Then it calls a method in the app to change the period of the timer that will start the meter reading routine, After the app routine finishes, control comes back to the button.Action that started the update. The session.Close then fires. The browser is still active and the menu will load a different page. But the session is gone and an attempt to save anything else causes an error. With a break point set in the session.Close, sometimes I have to step though multiple times before the event stops firing.
Is there a way to prevent the session from being lost other than copying the app routines into the session so everything runs in the session? I believe the problem happens because the app is also updating the database.