在应用程序退出时执行代码

Execute code on app exit

游戏应用每隔几秒将用户的进度存储到一个文件中。但是,如果用户在存储该数据之前退出应用程序,则部分数据可能不会存储。

有没有办法在用户尝试关闭应用时立即 运行 指定代码?类似于 on_exit 事件。

App class there's an on_stop event that can be used, or directly use the on_stop方法中(EventHandler)。