我有一个 AIR 应用程序,其中定义了以下 EXIT 处理程序:
NativeApplication.nativeApplication.addEventListener(Event.EXITING, applicationExitHandler);
applicationExitHandler
通过 HttpService 发出异步注销请求。由于这是异步的,因此看起来应用程序的 exit() 方法在实际发出注销请求之前返回。
如何确保请求在 exit() 返回之前完成?
最佳答案
覆盖默认行为。取消这个事件。然后调用服务。向您的服务添加请求处理程序/故障处理程序。完成时调用结果或故障处理程序。这是您可以安全退出应用程序的时间(当然,如果注销失败,您可能需要额外处理)。来自docs :
exiting Dispatched when the application exit sequence is started.
The exiting event is dispatched when application exit is initiated by the operating system; for example, when a user issues the Cmd-Q key sequence on Mac OS X, or when the autoExit property of the NativeApplication object is true and the last application window is closed. Canceling this event prevents the application from exiting.
Note: Calling the NativeApplication exit() method does not cause an exiting event to be dispatched. To warn components of an impending exit, dispatch the exiting event before calling exit() The Event.EXITING constant defines the value of the type property of an exiting event object.
关于apache-flex - 处理 AIR 应用程序中的应用程序退出事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/589304/