Re: Sleep, NSWorkspaceWillSleepNotification, 30 seconds and the run loop
Re: Sleep, NSWorkspaceWillSleepNotification, 30 seconds and the run loop
- Subject: Re: Sleep, NSWorkspaceWillSleepNotification, 30 seconds and the run loop
- From: Jeff Johnson <email@hidden>
- Date: Wed, 30 Sep 2009 12:18:44 -0500
If by 'finagle' you mean 'run', then yes, that should work. ;-)
There's a little bit more detail here:
http://developer.apple.com/mac/library/qa/qa2004/qa1340.html
-Jeff
On Sep 30, 2009, at 11:59 AM, email@hidden wrote:
Before entering sleep I would like to send small amounts of data via
async instances of CFSocket to the local and some remote hosts.
So I register for the sleep notification:
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver: self
selector: @selector(appWillSleep:) name:
NSWorkspaceWillSleepNotification object: NULL];
And tell all my local and remote things to stop:
- (void) appWillSleep:(NSNotification*) note
{
[[thingHandler sharedInstance] stopAllRunningThings:self];
}
Now I presume that the 30 second sleep delay referred to in the docs
for NSWorkspaceWillSleepNotification means that my app can dawdle in
-appWillSleep for 30 seconds.
Is this correct?
If so then it seems likely that when this method returns the machine
may sleep before all the network data requests complete.
Is it possible to finagle the runloop within -appWillSleep to allow
my runloop attached CFSockets to persist for up to 30s before sleep
overpowers me?
Or have I got this all wrong?
Thanks
Jonathan Mitchell
Developer
http://www.mugginsoft.com
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please 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