tags:

views:

1371

answers:

1

I have an AIR app with the following EXIT handler defined:

  NativeApplication.nativeApplication.addEventListener(Event.EXITING, applicationExitHandler);

applicationExitHandler makes an asynchronous logout request via an HttpService. Since this is asynchronous, it looks like the Application's exit() method returns before the logout request is actually made.

How can I make sure the request completes before exit() returns?

+2  A: 

Override the default behavior. Cancel this event. Call the service then.Add a request handler/ fault handler to your service. On completion either the result or the fault handler is called. This is when you can safely exit the app (of course if signout fails, you may need extra processing). From the 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.

dirkgently
How do I override exit() ?
Mike Sickler
Ah, I cancel the EXITING event in my ExitHandler?
Mike Sickler
I have provided a link in my answer. Have a look.
dirkgently