我正在尝试控制Air Application的退出,但无法让应用程序实际退出。我正在使用带有extendedDesktop配置文件的Native进程,并在退出时尝试运行脚本。现在它似乎退出,但该过程仍在运行。我必须通过任务管理器结束这个过程。代码如下:
这是Exiting事件的事件处理程序。
function exit(){
//remove the exit event handler
air.NativeApplication.nativeApplication.removeEventHandler(air.Event.EXITING,exit);
//close the window
var winClosingEvent;
var win = air.NativeApplication.nativeApplication.openedWindows[0];
closingEvent = new air.Event(air.Event.CLOSING,false,true);
win.dispatchEvent(closingEvent);
win.close();
//dispatch an exit event and force exit
var exitingEvent = new air.Event(air.Event.EXITING, false, false);
air.NativeApplication.nativeApplication.dispatchEvent(exitingEvent);
air.NativeApplication.nativeApplication.exit();
}