Hi,
I am trying to work out the best way in running a function at a specific time that passes a string value to a function.
I am using a non-GUI app and I want to make it so that if I stop the B4J app and then start it again make it resume where it left off and not lose any delayed functions.
I was thinking of doing something like the following, but if I stop the B4J app and start it again it won't continue off where it was at and it would start from the beginning again.
I could set the sleep for 3 hours before it triggers the rest of the code, but if I stop the B4J app after 2 hours and then start it again, I don't want to wait 3 hours for the code to trigger and it should have to wait 1 hour since that is all that was left.
I was going to store the values in a SQL database so if I stop and start the B4J app it would remember the value, but it won't know how long it was running before it stopped.
As an example, think of it like an Uber. The user sets the time they want to be picked up and the pickup address in the B4A/B4i app. It sends the time and address to the B4J app. In the B4J app, the B4J app should trigger the function at the time the user entered and pass the address at that time. There could be over 1000-2000 users.
Any ideas on how I can run the function as specific time, even if I start/stop/start the B4J app ?
I am trying to work out the best way in running a function at a specific time that passes a string value to a function.
I am using a non-GUI app and I want to make it so that if I stop the B4J app and then start it again make it resume where it left off and not lose any delayed functions.
I was thinking of doing something like the following, but if I stop the B4J app and start it again it won't continue off where it was at and it would start from the beginning again.
I could set the sleep for 3 hours before it triggers the rest of the code, but if I stop the B4J app after 2 hours and then start it again, I don't want to wait 3 hours for the code to trigger and it should have to wait 1 hour since that is all that was left.
B4X:
RunMeTimeDelay(15000,"HelloWorld1") ' run function in 15 seconds
RunMeTimeDelay(5000,"HelloWorld2") ' run function in 5 seconds
ActivateFunction("HelloWorld3") ' Run it instantly
Sub RunMeTimeDelay(time As Int, value As String)
Sleep(time)
ActivateFunction(value)
End Sub
Sub ActivateFunction(value As String)
Log(value)
End Sub
I was going to store the values in a SQL database so if I stop and start the B4J app it would remember the value, but it won't know how long it was running before it stopped.
As an example, think of it like an Uber. The user sets the time they want to be picked up and the pickup address in the B4A/B4i app. It sends the time and address to the B4J app. In the B4J app, the B4J app should trigger the function at the time the user entered and pass the address at that time. There could be over 1000-2000 users.
Any ideas on how I can run the function as specific time, even if I start/stop/start the B4J app ?