I need to warn my user that closing the app might interrupt some important processes. I placed a msgbox2/wait for in sub application_background as shown below. But the msgbox doesn't actually appear until you relaunch the closed app. I've also tried this in application_inactive with the same result. How do I fix this?
B4X:
Private Sub Application_Background
Msgbox2("kill","This will stop the process.","Are you sure you want to leave?",Array("Yes","No"))
wait for Kill_click(buttontext As String)
End Sub
Sub Kill_click(Buttontext As String)
If Buttontext = "Yes" Then
MyService.socket1.close
MyService.Astream.close
MyService.Server.close
Else
Application_Start(NavControl)
End If
End Sub