Async operations in windowWillClose:
Async operations in windowWillClose:
- Subject: Async operations in windowWillClose:
- From: "Stephen F. Booth" <email@hidden>
- Date: Thu, 25 Jan 2007 09:38:45 -0800
I've run into an issue that I haven't been able to figure out. I
have an NSPersistentDocument subclass that interacts with another
process running on the local machine through sockets. When certain
state changes in the document occur they are sent to the other
process, which then streams the updates to a server. Specifically,
my document manages a library of audio files and the state changes
are play/pause events that are sent to the Last.fm client. The
client then sends the data to the Last.fm server at the correct time.
The issue I've run into is this: when the application is quit with an
audio file playing, I need to notify the Last.fm client. I have code
in windowWillClose: which queues the command and opens the socket in
preparation for sending the data. But, since this is all done
asynchronously, the socket never has a chance to connect (the connect
callback never is called) before the application quits. I know the
code works, because when a document is simply closed everything
functions like I intend. I've read and re-read the information on
"Graceful application termination" to no avail.
This seems like something that could be handled from
applicationShouldTerminate, but that method is called after
windowWillClose has already been called (and failed/quashed), so I
cannot iterate through any open documents at that point.
Any ideas/thoughts/suggestions?
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden